€•˜ˆŒsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ/translations/zh_CN/spi/spidev”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)”}”(hhh]”hŒChinese (Traditional)”…””}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ/translations/zh_TW/spi/spidev”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ/translations/it_IT/spi/spidev”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ/translations/ja_JP/spi/spidev”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ/translations/ko_KR/spi/spidev”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒPortuguese (Brazilian)”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ/translations/pt_BR/spi/spidev”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒSpanish”…””}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ/translations/sp_SP/spi/spidev”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒSPI userspace API”h]”hŒSPI userspace API”…””}”(hh¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhh·h²hh³Œ8/var/lib/git/docbuild/linux/Documentation/spi/spidev.rst”h´KubhŒ paragraph”“”)”}”(hŒÖSPI devices have a limited userspace API, supporting basic half-duplex read() and write() access to SPI slave devices. Using ioctl() requests, full duplex transfers and device I/O configuration are also available.”h]”hŒÖSPI devices have a limited userspace API, supporting basic half-duplex read() and write() access to SPI slave devices. Using ioctl() requests, full duplex transfers and device I/O configuration are also available.”…””}”(hhÍh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khh·h²hubhŒ literal_block”“”)”}”(hŒt#include #include #include #include #include ”h]”hŒt#include #include #include #include #include ”…””}”hhÝsbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1hÛh³hÊh´K hh·h²hubhÌ)”}”(hŒFSome reasons you might want to use this programming interface include:”h]”hŒFSome reasons you might want to use this programming interface include:”…””}”(hhíh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khh·h²hubhŒ block_quote”“”)”}”(hX* Prototyping in an environment that's not crash-prone; stray pointers in userspace won't normally bring down any Linux system. * Developing simple protocols used to talk to microcontrollers acting as SPI slaves, which you may need to change quite often. ”h]”hŒ bullet_list”“”)”}”(hhh]”(hŒ list_item”“”)”}”(hŒ~Prototyping in an environment that's not crash-prone; stray pointers in userspace won't normally bring down any Linux system. ”h]”hÌ)”}”(hŒ}Prototyping in an environment that's not crash-prone; stray pointers in userspace won't normally bring down any Linux system.”h]”hŒPrototyping in an environment that’s not crash-prone; stray pointers in userspace won’t normally bring down any Linux system.”…””}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khjubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubj)”}”(hŒ}Developing simple protocols used to talk to microcontrollers acting as SPI slaves, which you may need to change quite often. ”h]”hÌ)”}”(hŒ|Developing simple protocols used to talk to microcontrollers acting as SPI slaves, which you may need to change quite often.”h]”hŒ|Developing simple protocols used to talk to microcontrollers acting as SPI slaves, which you may need to change quite often.”…””}”(hj$h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ*”uh1jh³hÊh´Khhýubah}”(h]”h ]”h"]”h$]”h&]”uh1hûh³hÊh´Khh·h²hubhÌ)”}”(hŒÒOf course there are drivers that can never be written in userspace, because they need to access kernel interfaces (such as IRQ handlers or other layers of the driver stack) that are not accessible to userspace.”h]”hŒÒOf course there are drivers that can never be written in userspace, because they need to access kernel interfaces (such as IRQ handlers or other layers of the driver stack) that are not accessible to userspace.”…””}”(hjFh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khh·h²hubh¶)”}”(hhh]”(h»)”}”(hŒDEVICE CREATION, DRIVER BINDING”h]”hŒDEVICE CREATION, DRIVER BINDING”…””}”(hjWh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjTh²hh³hÊh´KubhÌ)”}”(hŒwThe spidev driver contains lists of SPI devices that are supported for the different hardware topology representations.”h]”hŒwThe spidev driver contains lists of SPI devices that are supported for the different hardware topology representations.”…””}”(hjeh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K!hjTh²hubhÌ)”}”(hŒGThe following are the SPI device tables supported by the spidev driver:”h]”hŒGThe following are the SPI device tables supported by the spidev driver:”…””}”(hjsh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K$hjTh²hubhü)”}”(hXD- struct spi_device_id spidev_spi_ids[]: list of devices that can be bound when these are defined using a struct spi_board_info with a .modalias field matching one of the entries in the table. - struct of_device_id spidev_dt_ids[]: list of devices that can be bound when these are defined using a Device Tree node that has a compatible string matching one of the entries in the table. - struct acpi_device_id spidev_acpi_ids[]: list of devices that can be bound when these are defined using a ACPI device object with a _HID matching one of the entries in the table. ”h]”j)”}”(hhh]”(j)”}”(hŒ¿struct spi_device_id spidev_spi_ids[]: list of devices that can be bound when these are defined using a struct spi_board_info with a .modalias field matching one of the entries in the table. ”h]”hÌ)”}”(hŒ¾struct spi_device_id spidev_spi_ids[]: list of devices that can be bound when these are defined using a struct spi_board_info with a .modalias field matching one of the entries in the table.”h]”hŒ¾struct spi_device_id spidev_spi_ids[]: list of devices that can be bound when these are defined using a struct spi_board_info with a .modalias field matching one of the entries in the table.”…””}”(hjŒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K&hjˆubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj…ubj)”}”(hŒ¾struct of_device_id spidev_dt_ids[]: list of devices that can be bound when these are defined using a Device Tree node that has a compatible string matching one of the entries in the table. ”h]”hÌ)”}”(hŒ½struct of_device_id spidev_dt_ids[]: list of devices that can be bound when these are defined using a Device Tree node that has a compatible string matching one of the entries in the table.”h]”hŒ½struct of_device_id spidev_dt_ids[]: list of devices that can be bound when these are defined using a Device Tree node that has a compatible string matching one of the entries in the table.”…””}”(hj¤h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K*hj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj…ubj)”}”(hŒ³struct acpi_device_id spidev_acpi_ids[]: list of devices that can be bound when these are defined using a ACPI device object with a _HID matching one of the entries in the table. ”h]”hÌ)”}”(hŒ²struct acpi_device_id spidev_acpi_ids[]: list of devices that can be bound when these are defined using a ACPI device object with a _HID matching one of the entries in the table.”h]”hŒ²struct acpi_device_id spidev_acpi_ids[]: list of devices that can be bound when these are defined using a ACPI device object with a _HID matching one of the entries in the table.”…””}”(hj¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K.hj¸ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj…ubeh}”(h]”h ]”h"]”h$]”h&]”j>Œ-”uh1jh³hÊh´K&hjubah}”(h]”h ]”h"]”h$]”h&]”uh1hûh³hÊh´K&hjTh²hubhÌ)”}”(hŒ×You are encouraged to add an entry for your SPI device name to relevant tables, if these don't already have an entry for the device. To do that, post a patch for spidev to the linux-spi@vger.kernel.org mailing list.”h]”(hŒ²You are encouraged to add an entry for your SPI device name to relevant tables, if these don’t already have an entry for the device. To do that, post a patch for spidev to the ”…””}”(hjÝh²hh³Nh´NubhŒ reference”“”)”}”(hŒlinux-spi@vger.kernel.org”h]”hŒlinux-spi@vger.kernel.org”…””}”(hjçh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”Œ mailto:linux-spi@vger.kernel.org”uh1jåhjÝubhŒ mailing list.”…””}”(hjÝh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K2hjTh²hubhÌ)”}”(hX It used to be supported to define an SPI device using the "spidev" name. For example, as .modalias = "spidev" or compatible = "spidev". But this is no longer supported by the Linux kernel and instead a real SPI device name as listed in one of the tables must be used.”h]”hXIt used to be supported to define an SPI device using the “spidev†name. For example, as .modalias = “spidev†or compatible = “spidevâ€. But this is no longer supported by the Linux kernel and instead a real SPI device name as listed in one of the tables must be used.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K6hjTh²hubhÌ)”}”(hŒmNot having a real SPI device name will lead to an error being printed and the spidev driver failing to probe.”h]”hŒmNot having a real SPI device name will lead to an error being printed and the spidev driver failing to probe.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K;hjTh²hubhÌ)”}”(hŒÏSysfs also supports userspace driven binding/unbinding of drivers to devices that do not bind automatically using one of the tables above. To make the spidev driver bind to such a device, use the following::”h]”hŒÎSysfs also supports userspace driven binding/unbinding of drivers to devices that do not bind automatically using one of the tables above. To make the spidev driver bind to such a device, use the following:”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K>hjTh²hubhÜ)”}”(hŒhecho spidev > /sys/bus/spi/devices/spiB.C/driver_override echo spiB.C > /sys/bus/spi/drivers/spidev/bind”h]”hŒhecho spidev > /sys/bus/spi/devices/spiB.C/driver_override echo spiB.C > /sys/bus/spi/drivers/spidev/bind”…””}”hj+sbah}”(h]”h ]”h"]”h$]”h&]”hëhìuh1hÛh³hÊh´KBhjTh²hubhÌ)”}”(hŒ÷When the spidev driver is bound to a SPI device, the sysfs node for the device will include a child device node with a "dev" attribute that will be understood by udev or mdev (udev replacement from BusyBox; it's less featureful, but often enough).”h]”hŒýWhen the spidev driver is bound to a SPI device, the sysfs node for the device will include a child device node with a “dev†attribute that will be understood by udev or mdev (udev replacement from BusyBox; it’s less featureful, but often enough).”…””}”(hj9h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KEhjTh²hubhÌ)”}”(hŒjÖuh1jh³hÊh´K›hjvubah}”(h]”h ]”h"]”h$]”h&]”uh1hûh³hÊh´K›hj/h²hubeh}”(h]”Œbasic-character-device-api”ah ]”h"]”Œbasic character device api”ah$]”h&]”uh1hµhh·h²hh³hÊh´Klubh¶)”}”(hhh]”(h»)”}”(hŒ FULL DUPLEX CHARACTER DEVICE API”h]”hŒ FULL DUPLEX CHARACTER DEVICE API”…””}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj h²hh³hÊh´K¯ubhÌ)”}”(hXgSee the spidev_fdx.c sample program for one example showing the use of the full duplex programming interface. (Although it doesn't perform a full duplex transfer.) The model is the same as that used in the kernel spi_sync() request; the individual transfers offer the same capabilities as are available to kernel drivers (except that it's not asynchronous).”h]”hXkSee the spidev_fdx.c sample program for one example showing the use of the full duplex programming interface. (Although it doesn’t perform a full duplex transfer.) The model is the same as that used in the kernel spi_sync() request; the individual transfers offer the same capabilities as are available to kernel drivers (except that it’s not asynchronous).”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K±hj h²hubhÌ)”}”(hXŽThe example shows one half-duplex RPC-style request and response message. These requests commonly require that the chip not be deselected between the request and response. Several such requests could be chained into a single kernel request, even allowing the chip to be deselected after each response. (Other protocol options include changing the word size and bitrate for each transfer segment.)”h]”hXŽThe example shows one half-duplex RPC-style request and response message. These requests commonly require that the chip not be deselected between the request and response. Several such requests could be chained into a single kernel request, even allowing the chip to be deselected after each response. (Other protocol options include changing the word size and bitrate for each transfer segment.)”…””}”(hj(h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K·hj h²hubhÌ)”}”(hŒ€To make a full duplex request, provide both rx_buf and tx_buf for the same transfer. It's even OK if those are the same buffer.”h]”hŒ‚To make a full duplex request, provide both rx_buf and tx_buf for the same transfer. It’s even OK if those are the same buffer.”…””}”(hj6h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K¾hj h²hubeh}”(h]”Œ full-duplex-character-device-api”ah ]”h"]”Œ full duplex character device api”ah$]”h&]”uh1hµhh·h²hh³hÊh´K¯ubeh}”(h]”Œspi-userspace-api”ah ]”h"]”Œspi userspace api”ah$]”h&]”uh1hµhhh²hh³hÊh´Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÊuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)”}”(hºNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jwŒerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÊŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(jQjNj,j)jjjIjFuŒ nametypes”}”(jQ‰j,‰j‰jI‰uh}”(jNh·j)jTjj/jFj uŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nh²hub.