void fill_lb_gpios(struct lb_gpios *gpios) { struct exynos5_gpio_part1 *gpio_pt1; struct exynos5_gpio_part2 *gpio_pt2; gpios->size = sizeof(*gpios) + (GPIO_COUNT * sizeof(struct lb_gpio)); gpios->count = GPIO_COUNT; gpio_pt1 = (struct exynos5_gpio_part1 *)EXYNOS5_GPIO_PART1_BASE; gpio_pt2 = (struct exynos5_gpio_part2 *)EXYNOS5_GPIO_PART2_BASE; /* Write Protect: active Low */ gpios->gpios[0].port = EXYNOS5_GPD1; gpios->gpios[0].polarity = ACTIVE_LOW; gpios->gpios[0].value = s5p_gpio_get_value(&gpio_pt1->d1, WP_GPIO); strncpy((char *)gpios->gpios[0].name,"write protect", GPIO_MAX_NAME_LENGTH); /* Recovery: active high */ gpios->gpios[1].port = EXYNOS5_GPY1; gpios->gpios[1].polarity = ACTIVE_HIGH; gpios->gpios[2].value = s5p_gpio_get_value(&gpio_pt1->y1, FORCE_RECOVERY_MODE); strncpy((char *)gpios->gpios[1].name,"recovery", GPIO_MAX_NAME_LENGTH); /* Lid: the "switch" comes from the EC */ gpios->gpios[2].port = EXYNOS5_GPX3; gpios->gpios[2].polarity = ACTIVE_LOW; gpios->gpios[2].value = s5p_gpio_get_value(&gpio_pt2->x3, LID_OPEN); strncpy((char *)gpios->gpios[2].name,"lid", GPIO_MAX_NAME_LENGTH); /* Power: virtual GPIO active low */ gpios->gpios[3].port = -1; gpios->gpios[3].polarity = ACTIVE_LOW; gpios->gpios[3].value = 1; strncpy((char *)gpios->gpios[3].name,"power", GPIO_MAX_NAME_LENGTH); /* Developer: virtual GPIO active high */ gpios->gpios[4].port = -1; gpios->gpios[4].polarity = ACTIVE_HIGH; gpios->gpios[4].value = 0; strncpy((char *)gpios->gpios[4].name,"developer", GPIO_MAX_NAME_LENGTH); /* Was VGA Option ROM loaded? */ gpios->gpios[5].port = -1; /* Indicate that this is a pseudo GPIO */ gpios->gpios[5].polarity = ACTIVE_HIGH; gpios->gpios[5].value = 0; strncpy((char *)gpios->gpios[5].name,"oprom", GPIO_MAX_NAME_LENGTH); printk(BIOS_ERR, "Added %d GPIOS size %d\n", GPIO_COUNT, gpios->size); }
static void check_hw_revision(void) { int modelrev = 0; int i; gpio2 = (struct exynos4x12_gpio_part2 *)samsung_get_base_gpio_part2(); /* * GPM1[1:0]: MODEL_REV[1:0] * Don't set as pull-none for these N/C pin. * TRM say that it may cause unexcepted state and leakage current. * and pull-none is only for output function. */ for (i = 0; i < 2; i++) s5p_gpio_cfg_pin(&gpio2->m1, i, GPIO_INPUT); /* GPM1[5:2]: HW_REV[3:0] */ for (i = 2; i < 6; i++) { s5p_gpio_cfg_pin(&gpio2->m1, i, GPIO_INPUT); s5p_gpio_set_pull(&gpio2->m1, i, GPIO_PULL_NONE); } /* GPM1[1:0]: MODEL_REV[1:0] */ for (i = 0; i < 2; i++) modelrev |= (s5p_gpio_get_value(&gpio2->m1, i) << i); /* board_rev[15:8] = model */ board_rev = modelrev << 8; }
int board_mmc_init(bd_t *bis) { int i, ret, ret_sd = 0; /* MASSMEMORY_EN: XMSMDATA7: GPJ2[7] output high */ s5p_gpio_direction_output(&s5pc110_gpio->j2, 7, 1); /* * MMC0 GPIO * GPG0[0] SD_0_CLK * GPG0[1] SD_0_CMD * GPG0[2] SD_0_CDn -> Not used * GPG0[3:6] SD_0_DATA[0:3] */ for (i = 0; i < 7; i++) { if (i == 2) continue; /* GPG0[0:6] special function 2 */ s5p_gpio_cfg_pin(&s5pc110_gpio->g0, i, 0x2); /* GPG0[0:6] pull disable */ s5p_gpio_set_pull(&s5pc110_gpio->g0, i, GPIO_PULL_NONE); /* GPG0[0:6] drv 4x */ s5p_gpio_set_drv(&s5pc110_gpio->g0, i, GPIO_DRV_4X); } ret = s5p_mmc_init(0, 4); if (ret) error("MMC: Failed to init MMC:0.\n"); /* * SD card (T_FLASH) detect and init * T_FLASH_DETECT: EINT28: GPH3[4] input mode */ s5p_gpio_cfg_pin(&s5pc110_gpio->h3, 4, GPIO_INPUT); s5p_gpio_set_pull(&s5pc110_gpio->h3, 4, GPIO_PULL_UP); if (!s5p_gpio_get_value(&s5pc110_gpio->h3, 4)) { for (i = 0; i < 7; i++) { if (i == 2) continue; /* GPG2[0:6] special function 2 */ s5p_gpio_cfg_pin(&s5pc110_gpio->g2, i, 0x2); /* GPG2[0:6] pull disable */ s5p_gpio_set_pull(&s5pc110_gpio->g2, i, GPIO_PULL_NONE); /* GPG2[0:6] drv 4x */ s5p_gpio_set_drv(&s5pc110_gpio->g2, i, GPIO_DRV_4X); } ret_sd = s5p_mmc_init(2, 4); if (ret_sd) error("MMC: Failed to init SD card (MMC:2).\n"); } return ret & ret_sd; }
int board_mmc_init(bd_t *bis) { int err; switch (get_hwrev()) { case 0: /* * Set the low to enable LDO_EN * But when you use the test board for eMMC booting * you should set it HIGH since it removes the inverter */ /* MASSMEMORY_EN: XMDMDATA_6: GPE3[6] */ s5p_gpio_direction_output(&gpio1->e3, 6, 0); break; default: /* * Default reset state is High and there's no inverter * But set it as HIGH to ensure */ /* MASSMEMORY_EN: XMDMADDR_3: GPE1[3] */ s5p_gpio_direction_output(&gpio1->e1, 3, 1); break; } /* * MMC device init * mmc0 : eMMC (8-bit buswidth) * mmc2 : SD card (4-bit buswidth) */ err = exynos_pinmux_config(PERIPH_ID_SDMMC0, PINMUX_FLAG_8BIT_MODE); if (err) debug("SDMMC0 not configured\n"); else err = s5p_mmc_init(0, 8); /* T-flash detect */ s5p_gpio_cfg_pin(&gpio2->x3, 4, 0xf); s5p_gpio_set_pull(&gpio2->x3, 4, GPIO_PULL_UP); /* * Check the T-flash detect pin * GPX3[4] T-flash detect pin */ if (!s5p_gpio_get_value(&gpio2->x3, 4)) { err = exynos_pinmux_config(PERIPH_ID_SDMMC2, PINMUX_FLAG_NONE); if (err) debug("SDMMC2 not configured\n"); else err = s5p_mmc_init(2, 4); } return err; }
int board_mmc_init(bd_t *bis) { struct exynos4_gpio_part2 *gpio = (struct exynos4_gpio_part2 *)samsung_get_base_gpio_part2(); int err; /* eMMC_EN: SD_0_CDn: GPK0[2] Output High */ s5p_gpio_direction_output(&gpio->k0, 2, 1); s5p_gpio_set_pull(&gpio->k0, 2, GPIO_PULL_NONE); /* * MMC device init * mmc0 : eMMC (8-bit buswidth) * mmc2 : SD card (4-bit buswidth) */ err = exynos_pinmux_config(PERIPH_ID_SDMMC0, PINMUX_FLAG_8BIT_MODE); if (err) debug("SDMMC0 not configured\n"); else err = s5p_mmc_init(0, 8); /* T-flash detect */ s5p_gpio_cfg_pin(&gpio->x3, 4, 0xf); s5p_gpio_set_pull(&gpio->x3, 4, GPIO_PULL_UP); /* * Check the T-flash detect pin * GPX3[4] T-flash detect pin */ if (!s5p_gpio_get_value(&gpio->x3, 4)) { err = exynos_pinmux_config(PERIPH_ID_SDMMC2, PINMUX_FLAG_NONE); if (err) debug("SDMMC2 not configured\n"); else err = s5p_mmc_init(2, 4); } return err; }
static unsigned int get_hw_revision(void) { struct exynos4_gpio_part1 *gpio = (struct exynos4_gpio_part1 *)samsung_get_base_gpio_part1(); int hwrev = 0; int i; /* hw_rev[3:0] == GPE1[3:0] */ for (i = 0; i < 4; i++) { s5p_gpio_cfg_pin(&gpio->e1, i, GPIO_INPUT); s5p_gpio_set_pull(&gpio->e1, i, GPIO_PULL_NONE); } udelay(1); for (i = 0; i < 4; i++) hwrev |= (s5p_gpio_get_value(&gpio->e1, i) << i); debug("hwrev 0x%x\n", hwrev); return hwrev; }
int gpio_get_value(unsigned gpio) { return (int) s5p_gpio_get_value(s5p_gpio_get_bank(gpio), s5p_gpio_get_pin(gpio)); }
int gpio_get_value(int nr) { return (int) s5p_gpio_get_value(s5p_gpio_get_bank(nr), s5p_gpio_get_pin(nr)); }
/* read GPIO IN value of pin 'gpio' */ static int exynos_gpio_get_value(struct udevice *dev, unsigned offset) { struct exynos_bank_info *state = dev_get_priv(dev); return s5p_gpio_get_value(state->bank, offset); }
int board_mmc_init(bd_t *bis) { int i, err; switch (get_hwrev()) { case 0: /* * Set the low to enable LDO_EN * But when you use the test board for eMMC booting * you should set it HIGH since it removes the inverter */ /* MASSMEMORY_EN: XMDMDATA_6: GPE3[6] */ s5p_gpio_direction_output(&gpio1->e3, 6, 0); break; default: /* * Default reset state is High and there's no inverter * But set it as HIGH to ensure */ /* MASSMEMORY_EN: XMDMADDR_3: GPE1[3] */ s5p_gpio_direction_output(&gpio1->e1, 3, 1); break; } /* * eMMC GPIO: * SDR 8-bit@48MHz at MMC0 * GPK0[0] SD_0_CLK(2) * GPK0[1] SD_0_CMD(2) * GPK0[2] SD_0_CDn -> Not used * GPK0[3:6] SD_0_DATA[0:3](2) * GPK1[3:6] SD_0_DATA[0:3](3) * * DDR 4-bit@26MHz at MMC4 * GPK0[0] SD_4_CLK(3) * GPK0[1] SD_4_CMD(3) * GPK0[2] SD_4_CDn -> Not used * GPK0[3:6] SD_4_DATA[0:3](3) * GPK1[3:6] SD_4_DATA[4:7](4) */ for (i = 0; i < 7; i++) { if (i == 2) continue; /* GPK0[0:6] special function 2 */ s5p_gpio_cfg_pin(&gpio2->k0, i, 0x2); /* GPK0[0:6] pull disable */ s5p_gpio_set_pull(&gpio2->k0, i, GPIO_PULL_NONE); /* GPK0[0:6] drv 4x */ s5p_gpio_set_drv(&gpio2->k0, i, GPIO_DRV_4X); } for (i = 3; i < 7; i++) { /* GPK1[3:6] special function 3 */ s5p_gpio_cfg_pin(&gpio2->k1, i, 0x3); /* GPK1[3:6] pull disable */ s5p_gpio_set_pull(&gpio2->k1, i, GPIO_PULL_NONE); /* GPK1[3:6] drv 4x */ s5p_gpio_set_drv(&gpio2->k1, i, GPIO_DRV_4X); } /* T-flash detect */ s5p_gpio_cfg_pin(&gpio2->x3, 4, 0xf); s5p_gpio_set_pull(&gpio2->x3, 4, GPIO_PULL_UP); /* * MMC device init * mmc0 : eMMC (8-bit buswidth) * mmc2 : SD card (4-bit buswidth) */ err = s5p_mmc_init(0, 8); /* * Check the T-flash detect pin * GPX3[4] T-flash detect pin */ if (!s5p_gpio_get_value(&gpio2->x3, 4)) { /* * SD card GPIO: * GPK2[0] SD_2_CLK(2) * GPK2[1] SD_2_CMD(2) * GPK2[2] SD_2_CDn -> Not used * GPK2[3:6] SD_2_DATA[0:3](2) */ for (i = 0; i < 7; i++) { if (i == 2) continue; /* GPK2[0:6] special function 2 */ s5p_gpio_cfg_pin(&gpio2->k2, i, 0x2); /* GPK2[0:6] pull disable */ s5p_gpio_set_pull(&gpio2->k2, i, GPIO_PULL_NONE); /* GPK2[0:6] drv 4x */ s5p_gpio_set_drv(&gpio2->k2, i, GPIO_DRV_4X); } err = s5p_mmc_init(2, 4); } return err; }