void __init mx28evk_init_pin_group(struct pin_desc *pins, unsigned count) { int i; struct pin_desc *pin; for (i = 0; i < count; i++) { pin = pins + i; if (pin->fun == PIN_GPIO) gpio_request(MXS_PIN_TO_GPIO(pin->id), pin->name); else mxs_request_pin(pin->id, pin->fun, pin->name); if (pin->drive) { mxs_set_strength(pin->id, pin->strength, pin->name); mxs_set_voltage(pin->id, pin->voltage, pin->name); } if (pin->pull) mxs_set_pullup(pin->id, pin->pullup, pin->name); if (pin->fun == PIN_GPIO) { if (pin->output) gpio_direction_output(MXS_PIN_TO_GPIO(pin->id), pin->data); else gpio_direction_input(MXS_PIN_TO_GPIO(pin->id)); } } }
int mx28evk_enet_gpio_init(void) { /* * reset phy * if init called after assert() called * nRST is already low and the following does nothing, * otherwise it asserts nRST to perform valid reset */ gpio_set_value_cansleep(MXS_PIN_TO_GPIO(PINID_ENET0_RX_CLK), 0); /* LAN8720a minimum reset hold time 100us */ udelay(200); gpio_set_value_cansleep(MXS_PIN_TO_GPIO(PINID_ENET0_RX_CLK), 1); /* LAN8720a output drive after nRST deassertion after max 800ns */ udelay(1); /* * FIXME: Additional delay needed during fec_enet_adjust_link() * or any of its subfunctions or else link won't be reported. * Tricky: enabled trace printks also produce that delay */ mdelay(1); return 0; }
static void mxs_request_pins(struct pin_desc *pins, int nr) { int i; struct pin_desc *pin; /* configure the pins */ for (i = 0; i < nr; i++) { pin = &pins[i]; if (pin->fun == PIN_GPIO) gpio_request(MXS_PIN_TO_GPIO(pin->id), pin->name); else mxs_request_pin(pin->id, pin->fun, pin->name); if (pin->drive) { mxs_set_strength(pin->id, pin->strength, pin->name); mxs_set_voltage(pin->id, pin->voltage, pin->name); } if (pin->pull) mxs_set_pullup(pin->id, pin->pullup, pin->name); if (pin->fun == PIN_GPIO) { if (pin->output) gpio_direction_output(MXS_PIN_TO_GPIO(pin->id), pin->data); else gpio_direction_input(MXS_PIN_TO_GPIO(pin->id)); } } }
int mx28evk_enet_gpio_init(void) { /* pwr */ //gpio_request(MXS_PIN_TO_GPIO(PINID_SSP1_DATA3), "ENET_PWR"); //gpio_direction_output(MXS_PIN_TO_GPIO(PINID_SSP1_DATA3), 0); for (i = 0; i < ARRAY_SIZE(mx28evk_eth_mode_pins); i++) { mxs_release_pin(mx28evk_eth_mode_pins[i].id, mx28evk_eth_mode_pins[i].name); } mx28evk_init_pin_group(mx28evk_eth_mode_pins, ARRAY_SIZE(mx28evk_eth_mode_pins)); /* reset phy */ gpio_request(MXS_PIN_TO_GPIO(PINID_SSP0_DETECT), "PHY_RESET"); gpio_direction_output(MXS_PIN_TO_GPIO(PINID_SSP0_DETECT), 0); mdelay(1); gpio_direction_output(MXS_PIN_TO_GPIO(PINID_SSP0_DETECT), 1); /* Most a reset should last from switch chip is 14ms */ mdelay(20); for (i = 0; i < ARRAY_SIZE(mx28evk_eth_mode_pins); i++) { mxs_release_pin(mx28evk_eth_mode_pins[i].id, mx28evk_eth_mode_pins[i].name); } mx28evk_init_pin_group(mx28evk_eth_pins, ARRAY_SIZE(mx28evk_eth_pins)); return 0; }
void __init mx28evk_pins_init(void) { mx28evk_init_pin_group(mx28evk_fixed_pins, ARRAY_SIZE(mx28evk_fixed_pins)); if (enable_ssp1) { pr_info("Initializing SSP1 pins\n"); mx28evk_init_pin_group(mx28evk_ssp1_pins, ARRAY_SIZE(mx28evk_ssp1_pins)); } else if (enable_gpmi) { pr_info("Initializing GPMI pins\n"); mx28evk_init_pin_group(mx28evk_gpmi_pins, ARRAY_SIZE(mx28evk_gpmi_pins)); } #if defined(CONFIG_SPI_MXS) || defined(CONFIG_SPI_MXS_MODULE) mx28evk_init_pin_group(mx28evk_spi_pins, ARRAY_SIZE(mx28evk_spi_pins)); #endif #if defined(CONFIG_FEC) || defined(CONFIG_FEC_MODULE)\ || defined(CONFIG_FEC_L2SWITCH) #ifdef CONFIG_MX28_ENET_ISSUE gpio_request(MXS_PIN_TO_GPIO(PINID_ENET0_RX_CLK), "PHY_RESET"); gpio_direction_output(MXS_PIN_TO_GPIO(PINID_ENET0_RX_CLK), 1); #endif mx28evk_init_pin_group(mx28evk_eth_pins, ARRAY_SIZE(mx28evk_eth_pins)); #endif }
void mx28evk_enet_assert_reset(void) { printk("Resetting external PHY...\n"); gpio_request(MXS_PIN_TO_GPIO(PINID_SSP0_DETECT), "PHY_RESET"); gpio_direction_output(MXS_PIN_TO_GPIO(PINID_SSP0_DETECT), 0); mdelay(1); }
int mx23evk_mma7450_pin_init(void) { /* intr */ gpio_request(MXS_PIN_TO_GPIO(PINID_GPMI_D14), "MMA7450_INTR1"); gpio_direction_input(MXS_PIN_TO_GPIO(PINID_GPMI_D14)); gpio_request(MXS_PIN_TO_GPIO(PINID_GPMI_D15), "MMA7450_INTR2"); gpio_direction_input(MXS_PIN_TO_GPIO(PINID_GPMI_D15)); return 0; }
static void flexcan_xcvr_enable(int id, int en) { static int pwdn; if (en) { if (!pwdn++) gpio_set_value(MXS_PIN_TO_GPIO(PINID_SSP1_CMD), 1); } else { if (!--pwdn) gpio_set_value(MXS_PIN_TO_GPIO(PINID_SSP1_CMD), 0); } }
void __init mx28_cpx2_pins_init(void) { mx28_cpx2_init_pin_group(mx28_cpx2_fixed_pins, ARRAY_SIZE(mx28_cpx2_fixed_pins)); if (enable_ssp1) { pr_info("Initializing SSP1 pins\n"); mx28_cpx2_init_pin_group(mx28_cpx2_ssp1_pins, ARRAY_SIZE(mx28_cpx2_ssp1_pins)); } else if (enable_gpmi) { pr_info("Initializing GPMI pins\n"); mx28_cpx2_init_pin_group(mx28_cpx2_gpmi_pins, ARRAY_SIZE(mx28_cpx2_gpmi_pins)); } #if (defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)) \ && (defined (CONFIG_LEDS_GPIO_PLATFORM) || defined (CONFIG_LEDS_GPIO_PLATFORM_MODULE) ) /* * The CPX2 platform uses GPIO 122 & 123 (aka 3_26 & 3_27) as network green & * yellow LEDs. These need at least 8mA drive strength. With this config * option, these pins are registered in mx28_cpx2.c with the leds-gpio * driver; however, neither the leds-gpio nor gpio drivers support setting the * drive strength of the GPIO pins; this is only supported in the MXS pinctrl * code, but if we try to initialize them here with init_pin_group(), this * routine calls gpio_request() to claim the pins, which then causes the * leds-gpio driver to fail with EBUSY when it tries to register them also. * * Therefore, we manually set the drive strength of these pins here, and * let the leds-gpio driver call gpio_request(). Note that we must supply * sysfs = 1 to prevent testing the gpio_request() lock. */ mxs_set_strength(PINID_SAIF1_SDATA0, PAD_8MA, 1, NULL); // GPIO 122 / 3_26 mxs_set_strength(PINID_SPDIF, PAD_8MA, 1, NULL); // GPIO 123 / 3_27 #endif #if defined(CONFIG_SPI_MXS) || defined(CONFIG_SPI_MXS_MODULE) mx28_cpx2_init_pin_group(mx28_cpx2_spi_pins, ARRAY_SIZE(mx28_cpx2_spi_pins)); #endif #if defined(CONFIG_FEC) || defined(CONFIG_FEC_MODULE)\ || defined(CONFIG_FEC_L2SWITCH) mx28_cpx2_init_pin_group(mx28_cpx2_eth_pins, ARRAY_SIZE(mx28_cpx2_eth_pins)); // Take the PHY out of reset gpio_request(MXS_PIN_TO_GPIO(PINID_PWM4) , "ENET0_RST#"); gpio_direction_output( MXS_PIN_TO_GPIO(PINID_PWM4) , 1 ); #endif }
int mx23evk_enet_gpio_init(void) { /* pwr */ gpio_request(MXS_PIN_TO_GPIO(PINID_SSP1_DATA3), "ENET_PWR"); gpio_direction_output(MXS_PIN_TO_GPIO(PINID_SSP1_DATA3), 0); /* reset phy */ gpio_request(MXS_PIN_TO_GPIO(PINID_ENET0_RX_CLK), "PHY_RESET"); gpio_direction_output(MXS_PIN_TO_GPIO(PINID_ENET0_RX_CLK), 0); gpio_direction_output(MXS_PIN_TO_GPIO(PINID_ENET0_RX_CLK), 1); return 0; }
void mx28evk_enet_io_lowerpower_exit(void) { int i; gpio_direction_output(MXS_PIN_TO_GPIO(PINID_SSP1_DATA3), 0); gpio_direction_output(MXS_PIN_TO_GPIO(PINID_ENET0_RX_CLK), 1); gpio_free(MXS_PIN_TO_GPIO(PINID_ENET0_TX_CLK)); for (i = 0; i < ARRAY_SIZE(mx28evk_eth_pins); i++) { gpio_free(MXS_PIN_TO_GPIO(mx28evk_eth_pins[i].id)); mxs_request_pin(mx28evk_eth_pins[i].id, mx28evk_eth_pins[i].fun, mx28evk_eth_pins[i].name); } }
int msg2133_pin_release(void) { #ifdef __hcit__ unsigned int irq_gpio = MXS_PIN_TO_GPIO(PINID_SSP1_DATA1); unsigned int reset_gpio = MXS_PIN_TO_GPIO(PINID_SSP1_DATA2); gpio_free(reset_gpio); gpio_free(irq_gpio); set_irq_type(gpio_to_irq(irq_gpio), IRQ_TYPE_NONE); #endif mxs_release_pins(msg2133_ts_pins, ARRAY_SIZE(msg2133_ts_pins)); return 0; }
static irqreturn_t beep_timer_handler(int irq, void *dev_id) { static int count = 0; if (count) { gpio_direction_output(MXS_PIN_TO_GPIO(mxs_leds[LED_BEEP]), 1); count = 0; } else{ gpio_direction_output(MXS_PIN_TO_GPIO(mxs_leds[LED_BEEP]), 0); count = 1; } __raw_writel(1 << 15,base + HW_TIMROT_TIMCTRL3_CLR); return IRQ_HANDLED; }
int mx28evk_enet_gpio_init(void) { int i; printk("Configure external PHY pins...\n"); for (i = 0; i < ARRAY_SIZE(mx28evk_eth_mode_pins); i++) { mxs_release_pin(mx28evk_eth_mode_pins[i].id, mx28evk_eth_mode_pins[i].name); } mx28evk_init_pin_group(mx28evk_eth_mode_pins, ARRAY_SIZE(mx28evk_eth_mode_pins)); /* pwr */ if (mxs_get_type(PINID_GPMI_RDY1) == PIN_GPIO) { gpio_request(MXS_PIN_TO_GPIO(PINID_GPMI_RDY1), "ENET_PWR"); gpio_direction_output(MXS_PIN_TO_GPIO(PINID_GPMI_RDY1), 0); } else if (mxs_get_type(PINID_LCD_D10) == PIN_GPIO) { gpio_request(MXS_PIN_TO_GPIO(PINID_LCD_D10), "ENET_PWR"); gpio_direction_output(MXS_PIN_TO_GPIO(PINID_LCD_D10), 0); } else { printk(KERN_ERR "Unable to determine correct EN_ENET_3.3V pin\n"); } /* reset phy */ // gpio_request(MXS_PIN_TO_GPIO(PINID_SSP0_DETECT), "PHY_RESET"); // gpio_direction_output(MXS_PIN_TO_GPIO(PINID_SSP0_DETECT), 0); // mdelay(1); printk("Release external PHY reset...\n"); gpio_direction_output(MXS_PIN_TO_GPIO(PINID_SSP0_DETECT), 1); mdelay(20); for (i = 0; i < ARRAY_SIZE(mx28evk_eth_mode_pins); i++) { mxs_release_pin(mx28evk_eth_mode_pins[i].id, mx28evk_eth_mode_pins[i].name); } mx28evk_init_pin_group(mx28evk_eth_pins, ARRAY_SIZE(mx28evk_eth_pins)); return 0; }
void mx28evk_enet_io_lowerpower_enter(void) { int i; //gpio_direction_output(MXS_PIN_TO_GPIO(PINID_SSP1_DATA3), 1); //gpio_direction_output(MXS_PIN_TO_GPIO(PINID_ENET0_RX_CLK), 0); //gpio_request(MXS_PIN_TO_GPIO(PINID_ENET0_TX_CLK), "ETH_INT"); //gpio_direction_output(MXS_PIN_TO_GPIO(PINID_ENET0_TX_CLK), 0); for (i = 0; i < ARRAY_SIZE(mx28evk_eth_pins); i++) { mxs_release_pin(mx28evk_eth_pins[i].id, mx28evk_eth_pins[i].name); gpio_request(MXS_PIN_TO_GPIO(mx28evk_eth_pins[i].id), mx28evk_eth_pins[i].name); gpio_direction_output( MXS_PIN_TO_GPIO(mx28evk_eth_pins[i].id), 0); }7 }
void mx28evk_enet_io_lowerpower_exit(void) { int i; if (mxs_get_type(PINID_GPMI_RDY1) == PIN_GPIO) { gpio_direction_output(MXS_PIN_TO_GPIO(PINID_GPMI_RDY1), 0); } else if (mxs_get_type(PINID_LCD_D10) == PIN_GPIO) { gpio_direction_output(MXS_PIN_TO_GPIO(PINID_LCD_D10), 0); } else { printk(KERN_ERR "Unable to determine correct EN_ENET_3.3V pin\n"); } //gpio_direction_output(MXS_PIN_TO_GPIO(PINID_ENET0_RX_CLK), 1); //gpio_free(MXS_PIN_TO_GPIO(PINID_ENET0_TX_CLK)); for (i = 0; i < ARRAY_SIZE(mx28evk_eth_pins); i++) { gpio_free(MXS_PIN_TO_GPIO(mx28evk_eth_pins[i].id)); mxs_request_pin(mx28evk_eth_pins[i].id, mx28evk_eth_pins[i].fun, mx28evk_eth_pins[i].name); } }
int msg2133_pin_init(void) { mxs_request_pins(msg2133_ts_pins, ARRAY_SIZE(msg2133_ts_pins)); #ifdef __hcit__ unsigned int irq_gpio = MXS_PIN_TO_GPIO(PINID_SSP1_DATA1); unsigned int reset_gpio = MXS_PIN_TO_GPIO(PINID_SSP1_DATA2); gpio_request(irq_gpio, "msg2133_irq"); gpio_request(reset_gpio, "msg2133_reset"); gpio_direction_output(reset_gpio, 0); gpio_direction_input(irq_gpio); printk ("%s: set_irq_type EDGE_FAILLING: irq_gpio: %d, to_irq: %d\n", __FUNCTION__, irq_gpio, gpio_to_irq(irq_gpio)); set_irq_type(gpio_to_irq(irq_gpio), IRQ_TYPE_EDGE_FALLING); #endif return 0; }
int mx28evk_enet_gpio_init(void) { /* pwr */ gpio_request(MXS_PIN_TO_GPIO(PINID_SSP1_DATA3), "ENET_PWR"); gpio_direction_output(MXS_PIN_TO_GPIO(PINID_SSP1_DATA3), 0); /* reset phy */ gpio_request(MXS_PIN_TO_GPIO(PINID_ENET0_RX_CLK), "PHY_RESET"); gpio_direction_output(MXS_PIN_TO_GPIO(PINID_ENET0_RX_CLK), 0); /* * Before timer bug fix(set wrong match value of timer), * mdelay(10) delay 50ms actually. * So change delay to 50ms after timer issue fix. */ mdelay(50); gpio_direction_output(MXS_PIN_TO_GPIO(PINID_ENET0_RX_CLK), 1); return 0; }
static void beep_timer_off(void) { __raw_writel(1 << 2,int_base +HW_ICOLL_INTERRUPTn_CLR(IRQ_TIMER3)); __raw_writel(BV_TIMROT_TIMCTRLn_SELECT__NEVER_TICK| BM_TIMROT_TIMCTRLn_IRQ_EN , base + HW_TIMROT_TIMCTRLn(3)); gpio_direction_output(MXS_PIN_TO_GPIO(mxs_leds[LED_BEEP]), 0); return; }
int mxs_spi_enc_pin_init(void) { unsigned gpio = MXS_PIN_TO_GPIO(PINID_SSP1_DATA1); mxs_request_pins(mx23evk_spi_pins, ARRAY_SIZE(mx23evk_spi_pins)); gpio_request(gpio, "ENC28J60_INTR"); gpio_direction_input(gpio); set_irq_type(gpio_to_irq(gpio), IRQ_TYPE_EDGE_FALLING); return 0; }
int mxs_spi_enc_pin_release(void) { unsigned gpio = MXS_PIN_TO_GPIO(PINID_SSP1_DATA1); gpio_free(gpio); set_irq_type(gpio_to_irq(gpio), IRQ_TYPE_NONE); /* release the pins */ mxs_release_pins(mx23evk_spi_pins, ARRAY_SIZE(mx23evk_spi_pins)); return 0; }
static void mxs_release_pins(struct pin_desc *pins, int nr) { int i; struct pin_desc *pin; /* release the pins */ for (i = 0; i < nr; i++) { pin = &pins[i]; if (pin->fun == PIN_GPIO) gpio_free(MXS_PIN_TO_GPIO(pin->id)); else mxs_release_pin(pin->id, pin->name); } }
int mxs_led_set(unsigned index, int value) { gpio_request(MXS_PIN_TO_GPIO(mxs_leds[index]), "LED"); if (index == LED_BEEP) { //gpio_direction_output(MXS_PIN_TO_GPIO(mxs_leds[index]), value); if (value) { if (BEEP_TIMER_OFF == beeptimer.flag) { beep_timer_on(); beeptimer.flag = BEEP_TIMER_ON; } } else { if (BEEP_TIMER_ON == beeptimer.flag) { beep_timer_off(); beeptimer.flag = BEEP_TIMER_OFF; } } } else { gpio_direction_output(MXS_PIN_TO_GPIO(mxs_leds[index]), !value); } return 0; }
static void i2c_device_init(void) { mma7450_platdata.int1 = gpio_to_irq(MXS_PIN_TO_GPIO(PINID_GPMI_D14)); mma7450_platdata.int2 = gpio_to_irq(MXS_PIN_TO_GPIO(PINID_GPMI_D15)); i2c_register_board_info(0, &mma7450_i2c_device, 1); }
static void spi_device_init(void) { spi_board_info[0].irq = gpio_to_irq(MXS_PIN_TO_GPIO(PINID_SSP1_DATA1)); spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info)); }
int mx28evk_enet_gpio_init(void) { #define EASY283 1 #if EASY283 #define PHYRESETPIN PINID_LCD_D16 #else #define PHYRESETPIN PINID_ENET0_RX_CLK #endif /* pwr */ // gpio_request(MXS_PIN_TO_GPIO(PINID_SSP1_DATA3), "ENET_PWR"); // gpio_direction_output(MXS_PIN_TO_GPIO(PINID_SSP1_DATA3), 0); /* reset phy */ gpio_request(MXS_PIN_TO_GPIO(PINID_LCD_D16), "PHY_RESET"); gpio_direction_output(MXS_PIN_TO_GPIO(PINID_LCD_D16), 1); gpio_direction_output(MXS_PIN_TO_GPIO(PINID_LCD_D16), 0); /* * Before timer bug fix(set wrong match value of timer), * mdelay(10) delay 50ms actually. * So change delay to 50ms after timer issue fix. */ mdelay(50); gpio_direction_output(MXS_PIN_TO_GPIO(PINID_LCD_D16), 1); /* modefy by zhuguojun 延时500毫秒后再一次复位, 以解决在直接从内核启动时,phy不能被探测的问题 */ mdelay(300); gpio_direction_output(MXS_PIN_TO_GPIO(PINID_LCD_D16), 0); mdelay(50); gpio_direction_output(MXS_PIN_TO_GPIO(PINID_LCD_D16), 1); #if defined(CONFIG_iMX_287) /* reset phy */ gpio_request(MXS_PIN_TO_GPIO(PINID_SPDIF), "PHY_RESET"); gpio_direction_output(MXS_PIN_TO_GPIO(PINID_SPDIF), 1); gpio_direction_output(MXS_PIN_TO_GPIO(PINID_SPDIF), 0); /* * Before timer bug fix(set wrong match value of timer), * mdelay(10) delay 50ms actually. * So change delay to 50ms after timer issue fix. */ mdelay(50); gpio_direction_output(MXS_PIN_TO_GPIO(PINID_SPDIF), 1); /* modefy by zhuguojun 延时500毫秒后再一次复位, 以解决在直接从内核启动时,phy不能被探测的问题 */ mdelay(500); gpio_direction_output(MXS_PIN_TO_GPIO(PINID_SPDIF), 0); mdelay(50); gpio_direction_output(MXS_PIN_TO_GPIO(PINID_SPDIF), 1); #endif return 0; }
int mx28evk_enet_gpio_assert(void) { gpio_set_value_cansleep(MXS_PIN_TO_GPIO(PINID_ENET0_RX_CLK), 0); return 0; }