Lines Matching +full:master +full:- +full:side
1 // SPDX-License-Identifier: GPL-2.0-only
3 * pti.c - PTI driver for cJTAG data extration
27 #include <linux/intel-pti.h>
40 #define MODEM_BASE_ID 71 /* modem master ID address */
41 #define CONTROL_ID 72 /* control master ID address */
42 #define CONSOLE_ID 73 /* console master ID address */
43 #define OS_BASE_ID 74 /* base OS master ID address */
44 #define APP_BASE_ID 80 /* base App master ID address */
83 * pti_write_to_aperture()- The private write function to PTI HW.
86 * a master and channel ID.
92 * master/channel ID, no two processes will be writing
94 * PTI-Output agent will send these out in the order that they arrived, and
111 * calculate the aperture offset from the base using the master and in pti_write_to_aperture()
114 aperture = drv_data->pti_ioaddr + (mc->master << 15) in pti_write_to_aperture()
115 + (mc->channel << 8); in pti_write_to_aperture()
118 final = len - (dwordcnt << 2); /* final = trailing bytes */ in pti_write_to_aperture()
121 dwordcnt--; in pti_write_to_aperture()
134 ptiword |= *p++ << (24-(8*i)); in pti_write_to_aperture()
141 * pti_control_frame_built_and_sent()- control frame build and send function.
143 * @mc: The master / channel structure on which the function
145 * @thread_name: The thread name associated with the master / channel or
148 * To be able to post process the PTI contents on host side, a control frame
149 * is added before sending any PTI content. So the host side knows on
150 * each PTI frame the name of the thread using a dedicated master / channel.
153 * This function builds this frame and sends it to a master ID CONTROL_ID.
165 struct pti_masterchannel mccontrol = {.master = CONTROL_ID, in pti_control_frame_built_and_sent()
178 comm[TASK_COMM_LEN-1] = 0; in pti_control_frame_built_and_sent()
187 snprintf(control_frame, CONTROL_FRAME_LEN, control_format, mc->master, in pti_control_frame_built_and_sent()
188 mc->channel, thread_name_p); in pti_control_frame_built_and_sent()
193 * pti_write_full_frame_to_aperture()- high level function to
197 * a master and channel ID.
215 * get_id()- Allocate a master and channel ID.
222 * @thread_name: The thread name associated with the master / channel or
226 * pti_masterchannel struct with master, channel ID address
229 * Each bit in the arrays ia_app and ia_os correspond to a master and
231 * every master there are 128 channel id's.
263 mc->master = base_id; in get_id()
264 mc->channel = ((i & 0xf)<<3) + j; in get_id()
265 /* write new master Id / channel Id allocation to channel control */ in get_id()
278 * pti_request_masterchannel()- Kernel API function used to allocate
279 * a master, channel ID address
282 * @type: 0- request Application master, channel aperture ID
284 * 1- request OS master, channel aperture ID write
286 * 2- request Modem master, channel aperture ID
289 * @thread_name: The thread name associated with the master / channel or
306 mc = get_id(drv_data->ia_app, MAX_APP_IDS, in pti_request_masterchannel()
311 mc = get_id(drv_data->ia_os, MAX_OS_IDS, in pti_request_masterchannel()
316 mc = get_id(drv_data->ia_modem, MAX_MODEM_IDS, in pti_request_masterchannel()
329 * pti_release_masterchannel()- Kernel API function used to release
330 * a master, channel ID address
333 * @mc: master, channel apeture ID address to be released. This
334 * will de-allocate the structure via kfree().
338 u8 master, channel, i; in pti_release_masterchannel() local
343 master = mc->master; in pti_release_masterchannel()
344 channel = mc->channel; in pti_release_masterchannel()
346 if (master == APP_BASE_ID) { in pti_release_masterchannel()
348 drv_data->ia_app[i] &= ~(0x80>>(channel & 0x7)); in pti_release_masterchannel()
349 } else if (master == OS_BASE_ID) { in pti_release_masterchannel()
351 drv_data->ia_os[i] &= ~(0x80>>(channel & 0x7)); in pti_release_masterchannel()
354 drv_data->ia_modem[i] &= ~(0x80>>(channel & 0x7)); in pti_release_masterchannel()
365 * pti_writedata()- Kernel API function used to write trace
368 * @mc: Master, channel aperture ID address to write to.
390 * Specific header comments made for PTI-related specifics.
394 * pti_tty_driver_open()- Open an Application master, channel aperture
410 * master IDs. These messages go through the PTI HW and out of
422 return tty_port_open(tty->port, tty, filp); in pti_tty_driver_open()
426 * pti_tty_driver_close()- close tty device and release Application
427 * master, channel aperture ID to the PTI device via tty device.
438 tty_port_close(tty->port, tty, filp); in pti_tty_driver_close()
442 * pti_tty_install()- Used to set up specific master-channels
455 int idx = tty->index; in pti_tty_install()
462 return -ENOMEM; in pti_tty_install()
465 pti_tty_data->mc = pti_request_masterchannel(0, NULL); in pti_tty_install()
467 pti_tty_data->mc = pti_request_masterchannel(2, NULL); in pti_tty_install()
469 if (pti_tty_data->mc == NULL) { in pti_tty_install()
471 return -ENXIO; in pti_tty_install()
473 tty->driver_data = pti_tty_data; in pti_tty_install()
480 * pti_tty_cleanup()- Used to de-allocate master-channel resources
487 struct pti_tty *pti_tty_data = tty->driver_data; in pti_tty_cleanup()
490 pti_release_masterchannel(pti_tty_data->mc); in pti_tty_cleanup()
492 tty->driver_data = NULL; in pti_tty_cleanup()
496 * pti_tty_driver_write()- Write trace debugging data through the char
510 struct pti_tty *pti_tty_data = tty->driver_data; in pti_tty_driver_write()
511 if ((pti_tty_data != NULL) && (pti_tty_data->mc != NULL)) { in pti_tty_driver_write()
512 pti_write_to_aperture(pti_tty_data->mc, (u8 *)buf, len); in pti_tty_driver_write()
520 return -EFAULT; in pti_tty_driver_write()
524 * pti_tty_write_room()- Always returns 2048.
534 * pti_char_open()- Open an Application master, channel aperture
538 * @filp: Output- will have a masterchannel struct set containing
552 * before assigning the value to filp->private_data. in pti_char_open()
557 return -ENOMEM; in pti_char_open()
558 filp->private_data = mc; in pti_char_open()
563 * pti_char_release()- Close a char channel to the PTI device. Part
567 * @filp: Contains private_data that contains the master, channel
575 pti_release_masterchannel(filp->private_data); in pti_char_release()
576 filp->private_data = NULL; in pti_char_release()
581 * pti_char_write()- Write trace debugging data through the char
585 * master, channel write ID.
594 * Notes: From side discussions with Alan Cox and experimenting
610 mc = filp->private_data; in pti_char_write()
616 return -ENOMEM; in pti_char_write()
620 if (len - n > USER_COPY_SIZE) in pti_char_write()
623 size = len - n; in pti_char_write()
627 return n ? n : -EFAULT; in pti_char_write()
663 * pti_console_write()- Write to the console that has been acquired.
671 static struct pti_masterchannel mc = {.master = CONSOLE_ID, in pti_console_write()
681 * pti_console_device()- Return the driver tty structure and set the
693 *index = c->index; in pti_console_device()
698 * pti_console_setup()- Initialize console variables used by the driver.
733 * pti_port_activate()- Used to start/initialize any items upon
748 if (port->tty->index == PTITTY_MINOR_START) in pti_port_activate()
754 * pti_port_shutdown()- Used to stop/shutdown any items upon the
765 if (port->tty->index == PTITTY_MINOR_START) in pti_port_shutdown()
780 * pti_pci_probe()- Used to detect pti on the pci bus and set
797 dev_dbg(&pdev->dev, "%s %s(%d): PTI PCI ID %04x:%04x\n", __FILE__, in pti_pci_probe()
798 __func__, __LINE__, pdev->vendor, pdev->device); in pti_pci_probe()
811 dev_err(&pdev->dev, in pti_pci_probe()
819 retval = -ENOMEM; in pti_pci_probe()
820 dev_err(&pdev->dev, in pti_pci_probe()
825 drv_data->pti_addr = pci_resource_start(pdev, pci_bar); in pti_pci_probe()
827 retval = pci_request_region(pdev, pci_bar, dev_name(&pdev->dev)); in pti_pci_probe()
829 dev_err(&pdev->dev, in pti_pci_probe()
834 drv_data->aperture_base = drv_data->pti_addr+APERTURE_14; in pti_pci_probe()
835 drv_data->pti_ioaddr = in pti_pci_probe()
836 ioremap((u32)drv_data->aperture_base, in pti_pci_probe()
838 if (!drv_data->pti_ioaddr) { in pti_pci_probe()
839 retval = -ENOMEM; in pti_pci_probe()
846 struct tty_port *port = &drv_data->port[a]; in pti_pci_probe()
848 port->ops = &tty_port_ops; in pti_pci_probe()
850 tty_port_register_device(port, pti_tty_driver, a, &pdev->dev); in pti_pci_probe()
869 * pti_pci_remove()- Driver exit method to remove PTI from
882 tty_port_destroy(&drv_data->port[a]); in pti_pci_remove()
885 iounmap(drv_data->pti_ioaddr); in pti_pci_remove()
901 * pti_init()- Overall entry/init call to the pti driver.
919 return -ENOMEM; in pti_init()
922 pti_tty_driver->driver_name = DRIVERNAME; in pti_init()
923 pti_tty_driver->name = TTYNAME; in pti_init()
924 pti_tty_driver->major = 0; in pti_init()
925 pti_tty_driver->minor_start = PTITTY_MINOR_START; in pti_init()
926 pti_tty_driver->type = TTY_DRIVER_TYPE_SYSTEM; in pti_init()
927 pti_tty_driver->subtype = SYSTEM_TYPE_SYSCONS; in pti_init()
928 pti_tty_driver->flags = TTY_DRIVER_REAL_RAW | in pti_init()
930 pti_tty_driver->init_termios = tty_std_termios; in pti_init()
963 * pti_exit()- Unregisters this module as a tty and pci driver.