drivers: ieee802154_mcr20a: convert to new GPIO API
Convert MCR20A 802154 controller driver to new GPIO API. Signed-off-by: Johann Fischer <j.fischer@phytec.de>
This commit is contained in:
parent
9ed9969a66
commit
3eecab88e6
|
@ -12,8 +12,9 @@
|
|||
reg = <0x0>;
|
||||
label = "mcr20a";
|
||||
spi-max-frequency = <4000000>;
|
||||
irqb-gpios = <&arduino_header 8 0>; /* D2 */
|
||||
reset-gpios = <&arduino_header 11 0>; /* D5 */
|
||||
irqb-gpios = <&arduino_header 8
|
||||
(GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; /* D2 */
|
||||
reset-gpios = <&arduino_header 11 GPIO_ACTIVE_LOW>; /* D5 */
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
|
|
|
@ -792,24 +792,16 @@ static inline void irqb_int_handler(struct device *port,
|
|||
k_sem_give(&mcr20a->isr_sem);
|
||||
}
|
||||
|
||||
static inline void set_reset(struct device *dev, u32_t value)
|
||||
{
|
||||
struct mcr20a_context *mcr20a = dev->driver_data;
|
||||
|
||||
gpio_pin_write(mcr20a->reset_gpio,
|
||||
DT_INST_0_NXP_MCR20A_RESET_GPIOS_PIN, value);
|
||||
}
|
||||
|
||||
static void enable_irqb_interrupt(struct mcr20a_context *mcr20a,
|
||||
bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
gpio_pin_enable_callback(mcr20a->irq_gpio,
|
||||
DT_INST_0_NXP_MCR20A_IRQB_GPIOS_PIN);
|
||||
} else {
|
||||
gpio_pin_disable_callback(mcr20a->irq_gpio,
|
||||
DT_INST_0_NXP_MCR20A_IRQB_GPIOS_PIN);
|
||||
}
|
||||
gpio_flags_t flags = enable
|
||||
? GPIO_INT_EDGE_TO_ACTIVE
|
||||
: GPIO_INT_DISABLE;
|
||||
|
||||
gpio_pin_interrupt_configure(mcr20a->irq_gpio,
|
||||
DT_INST_0_NXP_MCR20A_IRQB_GPIOS_PIN,
|
||||
flags);
|
||||
}
|
||||
|
||||
static inline void setup_gpio_callbacks(struct mcr20a_context *mcr20a)
|
||||
|
@ -1269,22 +1261,24 @@ static int power_on_and_setup(struct device *dev)
|
|||
{
|
||||
struct mcr20a_context *mcr20a = dev->driver_data;
|
||||
u8_t timeout = 6U;
|
||||
u32_t status;
|
||||
int pin;
|
||||
u8_t tmp = 0U;
|
||||
|
||||
if (!PART_OF_KW2XD_SIP) {
|
||||
set_reset(dev, 0);
|
||||
gpio_pin_set(mcr20a->reset_gpio,
|
||||
DT_INST_0_NXP_MCR20A_RESET_GPIOS_PIN, 1);
|
||||
z_usleep(150);
|
||||
set_reset(dev, 1);
|
||||
gpio_pin_set(mcr20a->reset_gpio,
|
||||
DT_INST_0_NXP_MCR20A_RESET_GPIOS_PIN, 0);
|
||||
|
||||
do {
|
||||
z_usleep(50);
|
||||
timeout--;
|
||||
gpio_pin_read(mcr20a->irq_gpio,
|
||||
DT_INST_0_NXP_MCR20A_IRQB_GPIOS_PIN, &status);
|
||||
} while (status && timeout);
|
||||
pin = gpio_pin_get(mcr20a->irq_gpio,
|
||||
DT_INST_0_NXP_MCR20A_IRQB_GPIOS_PIN);
|
||||
} while (pin > 0 && timeout);
|
||||
|
||||
if (status) {
|
||||
if (pin) {
|
||||
LOG_ERR("Timeout, failed to get WAKE IRQ");
|
||||
return -EIO;
|
||||
}
|
||||
|
@ -1344,9 +1338,7 @@ static inline int configure_gpios(struct device *dev)
|
|||
|
||||
gpio_pin_configure(mcr20a->irq_gpio,
|
||||
DT_INST_0_NXP_MCR20A_IRQB_GPIOS_PIN,
|
||||
GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE |
|
||||
GPIO_PUD_PULL_UP |
|
||||
GPIO_INT_ACTIVE_LOW);
|
||||
GPIO_INPUT | DT_INST_0_NXP_MCR20A_IRQB_GPIOS_FLAGS);
|
||||
|
||||
if (!PART_OF_KW2XD_SIP) {
|
||||
/* setup gpio for the modems reset */
|
||||
|
@ -1361,8 +1353,8 @@ static inline int configure_gpios(struct device *dev)
|
|||
|
||||
gpio_pin_configure(mcr20a->reset_gpio,
|
||||
DT_INST_0_NXP_MCR20A_RESET_GPIOS_PIN,
|
||||
GPIO_DIR_OUT);
|
||||
set_reset(dev, 0);
|
||||
GPIO_OUTPUT_ACTIVE |
|
||||
DT_INST_0_NXP_MCR20A_RESET_GPIOS_FLAGS);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -11,7 +11,17 @@ properties:
|
|||
irqb-gpios:
|
||||
type: phandle-array
|
||||
required: true
|
||||
description: Interrupt pin.
|
||||
|
||||
The interrupt pin of MCR20A is open-drain, active low.
|
||||
If connected directly the MCU pin should be configured
|
||||
as pull-up, active low.
|
||||
|
||||
reset-gpios:
|
||||
type: phandle-array
|
||||
required: true
|
||||
description: RESET pin.
|
||||
|
||||
The RESET pin of MCR20A is active low.
|
||||
If connected directly the MCU pin should be configured
|
||||
as active low.
|
||||
|
|
Loading…
Reference in a new issue