~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/driver-api/serial/serial-iso7816.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/driver-api/serial/serial-iso7816.rst (Version linux-6.12-rc7) and /Documentation/driver-api/serial/serial-iso7816.rst (Version linux-6.1.116)


  1 =============================                       1 =============================
  2 ISO7816 Serial Communications                       2 ISO7816 Serial Communications
  3 =============================                       3 =============================
  4                                                     4 
  5 1. Introduction                                     5 1. Introduction
  6 ===============                                     6 ===============
  7                                                     7 
  8   ISO/IEC7816 is a series of standards specify      8   ISO/IEC7816 is a series of standards specifying integrated circuit cards (ICC)
  9   also known as smart cards.                        9   also known as smart cards.
 10                                                    10 
 11 2. Hardware-related considerations                 11 2. Hardware-related considerations
 12 ==================================                 12 ==================================
 13                                                    13 
 14   Some CPUs/UARTs (e.g., Microchip AT91) conta     14   Some CPUs/UARTs (e.g., Microchip AT91) contain a built-in mode capable of
 15   handling communication with a smart card.        15   handling communication with a smart card.
 16                                                    16 
 17   For these microcontrollers, the Linux driver     17   For these microcontrollers, the Linux driver should be made capable of
 18   working in both modes, and proper ioctls (se     18   working in both modes, and proper ioctls (see later) should be made
 19   available at user-level to allow switching f     19   available at user-level to allow switching from one mode to the other, and
 20   vice versa.                                      20   vice versa.
 21                                                    21 
 22 3. Data Structures Already Available in the Ke     22 3. Data Structures Already Available in the Kernel
 23 ==============================================     23 ==================================================
 24                                                    24 
 25   The Linux kernel provides the serial_iso7816     25   The Linux kernel provides the serial_iso7816 structure (see [1]) to handle
 26   ISO7816 communications. This data structure      26   ISO7816 communications. This data structure is used to set and configure
 27   ISO7816 parameters in ioctls.                    27   ISO7816 parameters in ioctls.
 28                                                    28 
 29   Any driver for devices capable of working bo     29   Any driver for devices capable of working both as RS232 and ISO7816 should
 30   implement the iso7816_config callback in the     30   implement the iso7816_config callback in the uart_port structure. The
 31   serial_core calls iso7816_config to do the d     31   serial_core calls iso7816_config to do the device specific part in response
 32   to TIOCGISO7816 and TIOCSISO7816 ioctls (see     32   to TIOCGISO7816 and TIOCSISO7816 ioctls (see below). The iso7816_config
 33   callback receives a pointer to struct serial     33   callback receives a pointer to struct serial_iso7816.
 34                                                    34 
 35 4. Usage from user-level                           35 4. Usage from user-level
 36 ========================                           36 ========================
 37                                                    37 
 38   From user-level, ISO7816 configuration can b     38   From user-level, ISO7816 configuration can be get/set using the previous
 39   ioctls. For instance, to set ISO7816 you can     39   ioctls. For instance, to set ISO7816 you can use the following code::
 40                                                    40 
 41         #include <linux/serial.h>                  41         #include <linux/serial.h>
 42                                                    42 
 43         /* Include definition for ISO7816 ioct     43         /* Include definition for ISO7816 ioctls: TIOCSISO7816 and TIOCGISO7816 */
 44         #include <sys/ioctl.h>                     44         #include <sys/ioctl.h>
 45                                                    45 
 46         /* Open your specific device (e.g., /d     46         /* Open your specific device (e.g., /dev/mydevice): */
 47         int fd = open ("/dev/mydevice", O_RDWR     47         int fd = open ("/dev/mydevice", O_RDWR);
 48         if (fd < 0) {                              48         if (fd < 0) {
 49                 /* Error handling. See errno.      49                 /* Error handling. See errno. */
 50         }                                          50         }
 51                                                    51 
 52         struct serial_iso7816 iso7816conf;         52         struct serial_iso7816 iso7816conf;
 53                                                    53 
 54         /* Reserved fields as to be zeroed */      54         /* Reserved fields as to be zeroed */
 55         memset(&iso7816conf, 0, sizeof(iso7816     55         memset(&iso7816conf, 0, sizeof(iso7816conf));
 56                                                    56 
 57         /* Enable ISO7816 mode: */                 57         /* Enable ISO7816 mode: */
 58         iso7816conf.flags |= SER_ISO7816_ENABL     58         iso7816conf.flags |= SER_ISO7816_ENABLED;
 59                                                    59 
 60         /* Select the protocol: */                 60         /* Select the protocol: */
 61         /* T=0 */                                  61         /* T=0 */
 62         iso7816conf.flags |= SER_ISO7816_T(0);     62         iso7816conf.flags |= SER_ISO7816_T(0);
 63         /* or T=1 */                               63         /* or T=1 */
 64         iso7816conf.flags |= SER_ISO7816_T(1);     64         iso7816conf.flags |= SER_ISO7816_T(1);
 65                                                    65 
 66         /* Set the guard time: */                  66         /* Set the guard time: */
 67         iso7816conf.tg = 2;                        67         iso7816conf.tg = 2;
 68                                                    68 
 69         /* Set the clock frequency*/               69         /* Set the clock frequency*/
 70         iso7816conf.clk = 3571200;                 70         iso7816conf.clk = 3571200;
 71                                                    71 
 72         /* Set transmission factors: */            72         /* Set transmission factors: */
 73         iso7816conf.sc_fi = 372;                   73         iso7816conf.sc_fi = 372;
 74         iso7816conf.sc_di = 1;                     74         iso7816conf.sc_di = 1;
 75                                                    75 
 76         if (ioctl(fd_usart, TIOCSISO7816, &iso     76         if (ioctl(fd_usart, TIOCSISO7816, &iso7816conf) < 0) {
 77                 /* Error handling. See errno.      77                 /* Error handling. See errno. */
 78         }                                          78         }
 79                                                    79 
 80         /* Use read() and write() syscalls her     80         /* Use read() and write() syscalls here... */
 81                                                    81 
 82         /* Close the device when finished: */      82         /* Close the device when finished: */
 83         if (close (fd) < 0) {                      83         if (close (fd) < 0) {
 84                 /* Error handling. See errno.      84                 /* Error handling. See errno. */
 85         }                                          85         }
 86                                                    86 
 87 5. References                                      87 5. References
 88 =============                                      88 =============
 89                                                    89 
 90  [1]    include/uapi/linux/serial.h                90  [1]    include/uapi/linux/serial.h
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php