2016-12-21 4 views
0

私のRasperry Pi用のLinuxカーネルモジュールでPWMを使用したいと思っています。私は正常にSYSFSインターフェイスを介してPWMを有効にしました。カーネルモジュールのドキュメント状態でPWMの使用方法については :linuxカーネルでのpwm_get()の使用例

新規ユーザーはpwm_get()関数を使用して、それに 民生機器や消費者の名を渡す必要があります。 pwm_put()は、PWM デバイスを解放するために使用されます。これらの関数であるdevm_pwm_get()と devm_pwm_put()の管理対象バリアントも存在します。私はDEVとcon_idを見つけることができます

/** 
* pwm_get() - look up and request a PWM device 
* @dev: device for PWM consumer 
* @con_id: consumer name 
.... 
*/ 
struct pwm_device *pwm_get(struct device *dev, const char *con_id) 

pwm_get機能は、次のようになりますか?デバイスツリーでそれらを定義する必要があると思われますが、それは唯一の疑いです。

+0

あなたが探している任意の識別子または文字列のためのカーネルを検索する[LXR](http://lxr.free-electrons.com/)を使用します。 – skrrgwasme

+0

a)デバイスツリー、またはb)ACPI(ただし別の方法で実行される)、またはc)スタティックルックアップテーブルを介してリソースを提供する必要があります。 – 0andriy

答えて

1

pwm_get()の1つの例は、Intel PWM backlight panelドライバで利用できます。
ここでは、その名前でPWMソースを取得するために使用されています。

/* Get the PWM chip for backlight control */ 
panel->backlight.pwm = pwm_get(dev->dev, "pwm_backlight"); 

PWMプロバイダ自体が ​​定義され...

/* PWM consumed by the Intel GFX */ 
static struct pwm_lookup crc_pwm_lookup[] = { 
     PWM_LOOKUP("crystal_cove_pwm", 0, "0000:00:02.0", "pwm_backlight", 0, PWM_POLARITY_NORMAL), 
}; 

...と hereを初期化。

/* Add lookup table for crc-pwm */ 
pwm_add_table(crc_pwm_lookup, ARRAY_SIZE(crc_pwm_lookup)); 

pwm-beeperpwm_get()の別の例です。

beeper->pwm = pwm_get(&pdev->dev, NULL); 

デバイスツリーの対応するエントリが存在します。here

buzzer { 
     compatible = "pwm-beeper"; 
     pwms = <&pwm 0 1000000 0>; 
     pinctrl-names = "default"; 
     pinctrl-0 = <&pwm0_out>; 
}; 

inline documentation of pwm_get()は、それを使用することができる方法の両方を記載します。

/** 
* pwm_get() - look up and request a PWM device 
* @dev: device for PWM consumer 
* @con_id: consumer name 
* 
* Lookup is first attempted using DT. If the device was not instantiated from 
* a device tree, a PWM chip and a relative index is looked up via a table 
* supplied by board setup code (see pwm_add_table()). 
* 
* Once a PWM chip has been found the specified PWM device will be requested 
* and is ready to be used. 
* 
* Returns: A pointer to the requested PWM device or an ERR_PTR()-encoded 
* error code on failure. 
*/ 
関連する問題