€•ÙnŒ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/driver-api/pwm”Œ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/driver-api/pwm”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/it_IT/driver-api/pwm”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/ja_JP/driver-api/pwm”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/ko_KR/driver-api/pwm”Œ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/driver-api/pwm”Œ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Œ&Pulse Width Modulation (PWM) interface”h]”hŒ&Pulse Width Modulation (PWM) interface”…””}”(hh¨hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hh£hžhhŸŒhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h Kfhj;ubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hj%ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j#hŸh¶h Kfhj ubj$)”}”(hŒ>export Exports a PWM channel for use with sysfs (write-only). ”h]”(j*)”}”(hŒexport”h]”hŒexport”…””}”(hj\hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j)hŸh¶h KihjXubj:)”}”(hhh]”h¸)”}”(hŒ6Exports a PWM channel for use with sysfs (write-only).”h]”hŒ6Exports a PWM channel for use with sysfs (write-only).”…””}”(hjmhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h Kihjjubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hjXubeh}”(h]”h ]”h"]”h$]”h&]”uh1j#hŸh¶h Kihj ubj$)”}”(hŒ:unexport Unexports a PWM channel from sysfs (write-only). ”h]”(j*)”}”(hŒunexport”h]”hŒunexport”…””}”(hj‹hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j)hŸh¶h Klhj‡ubj:)”}”(hhh]”h¸)”}”(hŒ0Unexports a PWM channel from sysfs (write-only).”h]”hŒ0Unexports a PWM channel from sysfs (write-only).”…””}”(hjœhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h Klhj™ubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hj‡ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j#hŸh¶h Klhj ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhjubah}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh¶h Kehjùhžhubh¸)”}”(hŒFThe PWM channels are numbered using a per-chip index from 0 to npwm-1.”h]”hŒFThe PWM channels are numbered using a per-chip index from 0 to npwm-1.”…””}”(hjÂhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h Knhjùhžhubh¸)”}”(hŒÙWhen a PWM channel is exported a pwmX directory will be created in the pwmchipN directory it is associated with, where X is the number of the channel that was exported. The following properties will then be available:”h]”hŒÙWhen a PWM channel is exported a pwmX directory will be created in the pwmchipN directory it is associated with, where X is the number of the channel that was exported. The following properties will then be available:”…””}”(hjÐhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h Kphjùhžhubj)”}”(hX<period The total period of the PWM signal (read/write). Value is in nanoseconds and is the sum of the active and inactive time of the PWM. duty_cycle The active time of the PWM signal (read/write). Value is in nanoseconds and must be less than or equal to the period. polarity Changes the polarity of the PWM signal (read/write). Writes to this property only work if the PWM chip supports changing the polarity. Value is the string "normal" or "inversed". enable Enable/disable the PWM signal (read/write). - 0 - disabled - 1 - enabled ”h]”j)”}”(hhh]”(j$)”}”(hŒ‹period The total period of the PWM signal (read/write). Value is in nanoseconds and is the sum of the active and inactive time of the PWM. ”h]”(j*)”}”(hŒperiod”h]”hŒperiod”…””}”(hjéhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j)hŸh¶h Kwhjåubj:)”}”(hhh]”h¸)”}”(hŒƒThe total period of the PWM signal (read/write). Value is in nanoseconds and is the sum of the active and inactive time of the PWM.”h]”hŒƒThe total period of the PWM signal (read/write). Value is in nanoseconds and is the sum of the active and inactive time of the PWM.”…””}”(hjúhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h Kuhj÷ubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hjåubeh}”(h]”h ]”h"]”h$]”h&]”uh1j#hŸh¶h Kwhjâubj$)”}”(hŒduty_cycle The active time of the PWM signal (read/write). Value is in nanoseconds and must be less than or equal to the period. ”h]”(j*)”}”(hŒ duty_cycle”h]”hŒ duty_cycle”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j)hŸh¶h K{hjubj:)”}”(hhh]”h¸)”}”(hŒuThe active time of the PWM signal (read/write). Value is in nanoseconds and must be less than or equal to the period.”h]”hŒuThe active time of the PWM signal (read/write). Value is in nanoseconds and must be less than or equal to the period.”…””}”(hj)hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h Kzhj&ubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hjubeh}”(h]”h ]”h"]”h$]”h&]”uh1j#hŸh¶h K{hjâubj$)”}”(hŒ¼polarity Changes the polarity of the PWM signal (read/write). Writes to this property only work if the PWM chip supports changing the polarity. Value is the string "normal" or "inversed". ”h]”(j*)”}”(hŒpolarity”h]”hŒpolarity”…””}”(hjGhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j)hŸh¶h KhjCubj:)”}”(hhh]”h¸)”}”(hŒ²Changes the polarity of the PWM signal (read/write). Writes to this property only work if the PWM chip supports changing the polarity. Value is the string "normal" or "inversed".”h]”hŒºChanges the polarity of the PWM signal (read/write). Writes to this property only work if the PWM chip supports changing the polarity. Value is the string “normal†or “inversedâ€.”…””}”(hjXhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K~hjUubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hjCubeh}”(h]”h ]”h"]”h$]”h&]”uh1j#hŸh¶h Khjâubj$)”}”(hŒYenable Enable/disable the PWM signal (read/write). - 0 - disabled - 1 - enabled ”h]”(j*)”}”(hŒenable”h]”hŒenable”…””}”(hjvhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j)hŸh¶h K‡hjrubj:)”}”(hhh]”(h¸)”}”(hŒ+Enable/disable the PWM signal (read/write).”h]”hŒ+Enable/disable the PWM signal (read/write).”…””}”(hj‡hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K„hj„ubj)”}”(hŒ- 0 - disabled - 1 - enabled ”h]”hŒ bullet_list”“”)”}”(hhh]”(hŒ list_item”“”)”}”(hŒ 0 - disabled”h]”h¸)”}”(hj¢h]”hŒ 0 - disabled”…””}”(hj¤hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K†hj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jžhj›ubjŸ)”}”(hŒ 1 - enabled ”h]”h¸)”}”(hŒ 1 - enabled”h]”hŒ 1 - enabled”…””}”(hj»hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K‡hj·ubah}”(h]”h ]”h"]”h$]”h&]”uh1jžhj›ubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ-”uh1j™hŸh¶h K†hj•ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh¶h K†hj„ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j9hjrubeh}”(h]”h ]”h"]”h$]”h&]”uh1j#hŸh¶h K‡hjâubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhjÞubah}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh¶h Kthjùhžhubeh}”(h]”Œ#using-pwms-with-the-sysfs-interface”ah ]”h"]”Œ#using pwms with the sysfs interface”ah$]”h&]”uh1h¡hh£hžhhŸh¶h K]ubh¢)”}”(hhh]”(h§)”}”(hŒImplementing a PWM driver”h]”hŒImplementing a PWM driver”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hjýhžhhŸh¶h KŠubh¸)”}”(hXNCurrently there are two ways to implement pwm drivers. Traditionally there only has been the barebone API meaning that each driver has to implement the pwm_*() functions itself. This means that it's impossible to have multiple PWM drivers in the system. For this reason it's mandatory for new drivers to use the generic PWM framework.”h]”hXRCurrently there are two ways to implement pwm drivers. Traditionally there only has been the barebone API meaning that each driver has to implement the pwm_*() functions itself. This means that it’s impossible to have multiple PWM drivers in the system. For this reason it’s mandatory for new drivers to use the generic PWM framework.”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h KŒhjýhžhubh¸)”}”(hX©A new PWM controller/chip can be allocated using pwmchip_alloc(), then registered using pwmchip_add() and removed again with pwmchip_remove(). To undo pwmchip_alloc() use pwmchip_put(). pwmchip_add() takes a filled in struct pwm_chip as argument which provides a description of the PWM chip, the number of PWM devices provided by the chip and the chip-specific implementation of the supported PWM operations to the framework.”h]”hX©A new PWM controller/chip can be allocated using pwmchip_alloc(), then registered using pwmchip_add() and removed again with pwmchip_remove(). To undo pwmchip_alloc() use pwmchip_put(). pwmchip_add() takes a filled in struct pwm_chip as argument which provides a description of the PWM chip, the number of PWM devices provided by the chip and the chip-specific implementation of the supported PWM operations to the framework.”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K’hjýhžhubh¸)”}”(hX‘When implementing polarity support in a PWM driver, make sure to respect the signal conventions in the PWM framework. By definition, normal polarity characterizes a signal starts high for the duration of the duty cycle and goes low for the remainder of the period. Conversely, a signal with inversed polarity starts low for the duration of the duty cycle and goes high for the remainder of the period.”h]”hX‘When implementing polarity support in a PWM driver, make sure to respect the signal conventions in the PWM framework. By definition, normal polarity characterizes a signal starts high for the duration of the duty cycle and goes low for the remainder of the period. Conversely, a signal with inversed polarity starts low for the duration of the duty cycle and goes high for the remainder of the period.”…””}”(hj*hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K™hjýhžhubh¸)”}”(hXDrivers are encouraged to implement ->apply() instead of the legacy ->enable(), ->disable() and ->config() methods. Doing that should provide atomicity in the PWM config workflow, which is required when the PWM controls a critical device (like a regulator).”h]”hXDrivers are encouraged to implement ->apply() instead of the legacy ->enable(), ->disable() and ->config() methods. Doing that should provide atomicity in the PWM config workflow, which is required when the PWM controls a critical device (like a regulator).”…””}”(hj8hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K hjýhžhubh¸)”}”(hŒÒThe implementation of ->get_state() (a method used to retrieve initial PWM state) is also encouraged for the same reason: letting the PWM user know about the current PWM state would allow him to avoid glitches.”h]”hŒÒThe implementation of ->get_state() (a method used to retrieve initial PWM state) is also encouraged for the same reason: letting the PWM user know about the current PWM state would allow him to avoid glitches.”…””}”(hjFhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K¥hjýhžhubh¸)”}”(hŒŠDrivers should not implement any power management. In other words, consumers should implement it as described in the "Using PWMs" section.”h]”hŒŽDrivers should not implement any power management. In other words, consumers should implement it as described in the “Using PWMs†section.”…””}”(hjThžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K©hjýhžhubeh}”(h]”Œimplementing-a-pwm-driver”ah ]”h"]”Œimplementing a pwm driver”ah$]”h&]”uh1h¡hh£hžhhŸh¶h KŠubh¢)”}”(hhh]”(h§)”}”(hŒLocking”h]”hŒLocking”…””}”(hjmhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hjjhžhhŸh¶h K­ubh¸)”}”(hXõThe PWM core list manipulations are protected by a mutex, so pwm_get() and pwm_put() may not be called from an atomic context. Most functions in the PWM consumer API might sleep and so must not be called from atomic context. The notable exception is pwm_apply_atomic() which has the same semantics as pwm_apply_might_sleep() but can be called from atomic context. (The price for that is that it doesn't work for all PWM devices, use pwm_might_sleep() to check if a given PWM supports atomic operation.”h]”hX÷The PWM core list manipulations are protected by a mutex, so pwm_get() and pwm_put() may not be called from an atomic context. Most functions in the PWM consumer API might sleep and so must not be called from atomic context. The notable exception is pwm_apply_atomic() which has the same semantics as pwm_apply_might_sleep() but can be called from atomic context. (The price for that is that it doesn’t work for all PWM devices, use pwm_might_sleep() to check if a given PWM supports atomic operation.”…””}”(hj{hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K¯hjjhžhubh¸)”}”(hŒWLocking in the PWM core ensures that callbacks related to a single chip are serialized.”h]”hŒWLocking in the PWM core ensures that callbacks related to a single chip are serialized.”…””}”(hj‰hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K·hjjhžhubeh}”(h]”Œlocking”ah ]”h"]”Œlocking”ah$]”h&]”uh1h¡hh£hžhhŸh¶h K­ubh¢)”}”(hhh]”(h§)”}”(hŒHelpers”h]”hŒHelpers”…””}”(hj¢hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hjŸhžhhŸh¶h K»ubh¸)”}”(hŒêCurrently a PWM can only be configured with period_ns and duty_ns. For several use cases freq_hz and duty_percent might be better. Instead of calculating this in your driver please consider adding appropriate helpers to the framework.”h]”hŒêCurrently a PWM can only be configured with period_ns and duty_ns. For several use cases freq_hz and duty_percent might be better. Instead of calculating this in your driver please consider adding appropriate helpers to the framework.”…””}”(hj°hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K½hjŸhžhubeh}”(h]”Œhelpers”ah ]”h"]”Œhelpers”ah$]”h&]”uh1h¡hh£hžhhŸh¶h K»ubeh}”(h]”Œ$pulse-width-modulation-pwm-interface”ah ]”h"]”Œ&pulse width modulation (pwm) interface”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”jñŒ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”}”(jËjÈjjjöjójúj÷jgjdjœj™jÃjÀuŒ nametypes”}”(jˉj‰jö‰jú‰jg‰jœ‰jÉuh}”(jÈh£jhÕjójj÷jùjdjýj™jjjÀjŸ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.