linux GPIOドライバを使用して、出力としてmpc8308プロセッサのGPIOピンの1つを処理します。私はGPIOドライバを有効にし、それがでデバッグです:linux gpioドライバはGPIOをエクスポートできません
Device Drivers ---> GPIO Support ---> /sys/class/gpio/... (sysfs interface)
が、GPIO21をエクスポートするecho
コマンドを使用している場合、それは無効な引数のerrnoを与える:
gpio_request: gpio-21 (sysfs) status -22
export_store: status -22
私は、GPIOピンを表示することがcat /sys/kernel/debug/gpio
を使用しました他のドライバーによって予約されていますが、何も表示されません。このピンはフリーです。
私は、エラーの場所のためのカーネルをハッキングし、gpiolib.cでgpio_request
関数の先頭にそれが怒鳴るの最後の行でクラッシュすることがわかった:
int gpio_request(unsigned gpio, const char *label)
{
struct gpio_desc *desc;
struct gpio_chip *chip;
int status = -EINVAL;
unsigned long flags;
spin_lock_irqsave(&gpio_lock, flags);
if (!gpio_is_valid(gpio))
goto done;
desc = &gpio_desc[gpio];
chip = desc->chip;
if (chip == NULL)
goto done
gpio_desc[gpio]
は、ドライバの配列のエントリです( static struct gpio_desc gpio_desc[ARCH_NR_GPIOS];
)は、ドライバでgpiochip_add
関数で初期化する必要があります。
/**
* gpiochip_add() - register a gpio_chip
* @chip: the chip to register, with chip->base initialized
* Context: potentially before irqs or kmalloc will work
*
* Returns a negative errno if the chip can't be registered, such as
* because the chip->base is invalid or already associated with a
* different chip. Otherwise it returns zero as a success code.
*
* When gpiochip_add() is called very early during boot, so that GPIOs
* can be freely used, the chip->dev device must be registered before
* the gpio framework's arch_initcall(). Otherwise sysfs initialization
* for GPIOs will fail rudely.
*
* If chip->base is negative, this requests dynamic assignment of
* a range of valid GPIOs.
*/
しかしgpiochip_add
機能は、起動中に呼び出されていないん:ドライバーが言うように、この機能を早期に呼び出さなければなりません。ここで
は.dtsファイルです:
[email protected] {
device_type = "gpio";
compatible = "fsl,mpc8315-gpio";
reg = <0xc00 0x100>; //reg = <0xc00 0x18>;
interrupt-parent = < &ipic >;
};
誰もがこの問題で私を助けることができますか?
編集:
私はこれまで、DTSファイルを変更:
gpio1: [email protected] {
#gpio-cells = <2>;
compatible = "fsl,mpc8308-gpio", "fsl,mpc8349-gpio";
reg = <0xc00 0x100>;
interrupt-parent = <&ipic>;
interrupts = <74 0x8>;
gpio-controller;
interrupt-controller;
#interrupt-cells = <2>;
};
を、今では/sys/class/gpio
でgpiochip224
を示しており、このgpiochipは、32個のGPIOを持っています。私は21と224-255の間のマッピングが何か分かりません。 データシートのPIN番号とMPC8308 PowerPCシリーズプロセッサのGPIO番号との関係は誰に教えてもらえますか?
エコー私は私の.dtsでGPIO-コントローラを持っていないし、また、私はpinctrlドライバを持っていませんカーネルで。私はgpio-controllerやpinctrl、あるいは両方をusetspaceのGPIOと連携させるべきでしょうか? – AVM
古いカーネルの場合、SICRHレジスタが正しく設定されていないバグがある可能性があります。 – gj13
ブート中にSICRHを設定しましたが、その値が正しく残っているかどうかはわかりません。 – AVM