출력으로 mpc8308 프로세서의 GPIO 핀 중 하나를 처리하기 위해 리눅스 GPIO 드라이버를 사용하고 싶습니다. 그래서 GPIO 드라이버를 사용할 수 있으며 디버깅을이다 :리눅스 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
사용을 다른 운전자가 예약했으나 아무것도 표시하지 않습니다. 그래서이 핀은 자유 다. (
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]
드라이버에서 배열의 항목입니다 :
gpio_request
기능의 처음에이 울부 짖는 소리에 마지막 줄에서 충돌 발견
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
기능은 부팅 중에 호출되지 않습니다 : 드라이버가 말한대로이 기능은 초기 호출해야합니다.
[email protected] {
device_type = "gpio";
compatible = "fsl,mpc8315-gpio";
reg = <0xc00 0x100>; //reg = <0xc00 0x18>;
interrupt-parent = < &ipic >;
};
사람이 문제를 도와 줄 수 있습니다 여기에
는 .dts 파일입니다?편집 :
나는 이것에 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 사이의 매핑이 무엇인지 모른다. 누구나 MPC8308 PowerPC 시리즈 프로세서의 커널에있는 데이터 시트의 PIN 번호와 GPIO 번호 사이의 관계를 말해 줄 수 있습니까? 나는 224-255의 숫자를 시도하고 그 중 아무 것도 작동하지 않습니다.
내 .dts에서하지 GPIO 컨트롤러가 있고 또한 내가 pinctrl 드라이버를하지 않은 커널에서. GPIO를 usetspace에서 사용하려면 gpio-controller 또는 pinctrl을 추가해야합니까? – AVM
오래된 커널이 있다면 SICRH 레지스터가 올바르게 설정되지 않은 버그가있을 수 있습니다. – gj13
부팅 중에 SICRH를 설정했지만 값이 올바르게 유지되는지 확신 할 수 없습니다. – AVM