ssize_t led_open(struct inode *inode,struct file *filep) { unsigned tmp; for(tmp=0;tmp<4;tmp++){ s3c_gpio_cfgpin(S3C64XX_GPM(tmp),S3C_GPIO_SFN(1)); gpio_set_value(S3C64XX_GPM(tmp),1); s3c_gpio_setpull(S3C64XX_GPM(tmp),S3C_GPIO_SFN(2)); } return 0; }
int gpio_to_irq(unsigned gpio) { if ( gpio >= S3C64XX_GPN(0) && gpio <= S3C64XX_GPN(15) ) return IRQ_EINT(gpio - S3C64XX_GPIO_N_START); else if ( gpio >= S3C64XX_GPL(8) && gpio <= S3C64XX_GPL(14) ) return IRQ_EINT(gpio - S3C64XX_GPL(8) + 16); else if ( gpio >= S3C64XX_GPM(0) && gpio <= S3C64XX_GPM(4) ) return IRQ_EINT(gpio - S3C64XX_GPM(0) + 23); return -EINVAL; }
static int __init smartq_lcd_setup_gpio(void) { int ret; ret = gpio_request(S3C64XX_GPM(3), "LCD power"); if (ret < 0) return ret; /* turn power off */ gpio_direction_output(S3C64XX_GPM(3), 0); return 0; }
static long unlocked_led_ioctl(struct file *filp,unsigned int cmd,unsigned long arg) { if(arg >3 || arg < 0) return -EINVAL; switch(cmd) { case LED_OFF: gpio_set_value(S3C64XX_GPM(arg),1); return 0; case LED_ON: gpio_set_value(S3C64XX_GPM(arg),0); return 0; default: return -EINVAL; } }
static void __init hmt_machine_init(void) { s3c_i2c0_set_platdata(NULL); s3c_fb_set_platdata(&hmt_lcd_pdata); s3c_nand_set_platdata(&hmt_nand_info); gpio_request(S3C64XX_GPC(7), "usb power"); gpio_direction_output(S3C64XX_GPC(7), 0); gpio_request(S3C64XX_GPM(0), "usb power"); gpio_direction_output(S3C64XX_GPM(0), 1); gpio_request(S3C64XX_GPK(7), "usb power"); gpio_direction_output(S3C64XX_GPK(7), 1); gpio_request(S3C64XX_GPF(13), "usb power"); gpio_direction_output(S3C64XX_GPF(13), 1); platform_add_devices(hmt_devices, ARRAY_SIZE(hmt_devices)); }
int irq_to_gpio(unsigned irq) { if (irq >= IRQ_EINT(0) && irq <= IRQ_EINT(15)) return S3C64XX_GPN(irq - IRQ_EINT(0)); else if (irq >= IRQ_EINT(16) && irq <= IRQ_EINT(22)) return S3C64XX_GPL(irq - IRQ_EINT(16) + 8); else if (irq >= IRQ_EINT(23) && irq <= IRQ_EINT(27)) return S3C64XX_GPM(irq - IRQ_EINT(23)); return -EINVAL; }
static void __init smartq5_lcd_setup_gpio(void) { gpio_request(S3C64XX_GPM(0), "LCD SCEN pin"); gpio_request(S3C64XX_GPM(1), "LCD SCL pin"); gpio_request(S3C64XX_GPM(2), "LCD SDA pin"); gpio_request(S3C64XX_GPM(3), "LCD power"); /* turn power off */ gpio_direction_output(S3C64XX_GPM(0), 1); gpio_direction_input(S3C64XX_GPM(1)); gpio_direction_input(S3C64XX_GPM(2)); gpio_direction_output(S3C64XX_GPM(3), 0); }
void s3c64xx_ide_setup_gpio(void) { u32 reg; reg = readl(S3C_MEM_SYS_CFG) & (~0x3f); /* Independent CF interface, CF chip select configuration */ writel(reg | MEM_SYS_CFG_INDEP_CF | MEM_SYS_CFG_EBI_FIX_PRI_CFCON, S3C_MEM_SYS_CFG); s3c_gpio_cfgpin(S3C64XX_GPB(4), S3C_GPIO_SFN(4)); /* Set XhiDATA[15:0] pins as CF Data[15:0] */ s3c_gpio_cfgpin_range(S3C64XX_GPK(0), 16, S3C_GPIO_SFN(5)); /* Set XhiADDR[2:0] pins as CF ADDR[2:0] */ s3c_gpio_cfgpin_range(S3C64XX_GPL(0), 3, S3C_GPIO_SFN(6)); /* Set Xhi ctrl pins as CF ctrl pins(IORDY, IOWR, IORD, CE[0:1]) */ s3c_gpio_cfgpin(S3C64XX_GPM(5), S3C_GPIO_SFN(1)); s3c_gpio_cfgpin_range(S3C64XX_GPM(0), 5, S3C_GPIO_SFN(6)); }
void s3c64xx_ide_setup_gpio(void) { u32 reg; reg = readl(S3C_MEM_SYS_CFG) & (~0x3f); writel(reg | MEM_SYS_CFG_INDEP_CF | MEM_SYS_CFG_EBI_FIX_PRI_CFCON, S3C_MEM_SYS_CFG); s3c_gpio_cfgpin(S3C64XX_GPB(4), S3C_GPIO_SFN(4)); s3c_gpio_cfgpin_range(S3C64XX_GPK(0), 16, S3C_GPIO_SFN(5)); s3c_gpio_cfgpin_range(S3C64XX_GPL(0), 3, S3C_GPIO_SFN(6)); s3c_gpio_cfgpin(S3C64XX_GPM(5), S3C_GPIO_SFN(1)); s3c_gpio_cfgpin_range(S3C64XX_GPM(0), 5, S3C_GPIO_SFN(6)); }
static void __init smartq7_lcd_setup_gpio(void) { gpio_request(S3C64XX_GPM(0), "LCD CSB pin"); gpio_request(S3C64XX_GPM(3), "LCD power"); gpio_request(S3C64XX_GPM(4), "LCD power status"); /* turn power off */ gpio_direction_output(S3C64XX_GPM(0), 1); gpio_direction_output(S3C64XX_GPM(3), 0); gpio_direction_input(S3C64XX_GPM(4)); }
static void __init crag6410_machine_init(void) { /* Open drain IRQs need pullups */ s3c_gpio_setpull(S3C64XX_GPM(0), S3C_GPIO_PULL_UP); s3c_gpio_setpull(S3C64XX_GPN(0), S3C_GPIO_PULL_UP); gpio_request(S3C64XX_GPB(0), "LCD power"); gpio_direction_output(S3C64XX_GPB(0), 0); gpio_request(S3C64XX_GPF(14), "LCD PWM"); gpio_direction_output(S3C64XX_GPF(14), 0); /* turn off */ gpio_request(S3C64XX_GPB(1), "SD power"); gpio_direction_output(S3C64XX_GPB(1), 0); gpio_request(S3C64XX_GPF(10), "nRESETSEL"); gpio_direction_output(S3C64XX_GPF(10), 1); s3c_sdhci0_set_platdata(&crag6410_hsmmc0_pdata); s3c_sdhci2_set_platdata(&crag6410_hsmmc2_pdata); s3c_i2c0_set_platdata(&i2c0_pdata); s3c_i2c1_set_platdata(&i2c1_pdata); s3c_fb_set_platdata(&crag6410_lcd_pdata); dwc2_hsotg_set_platdata(&crag6410_hsotg_pdata); i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0)); i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1)); samsung_keypad_set_platdata(&crag6410_keypad_data); s3c64xx_spi0_set_platdata(NULL, 0, 2); pwm_add_table(crag6410_pwm_lookup, ARRAY_SIZE(crag6410_pwm_lookup)); platform_add_devices(crag6410_devices, ARRAY_SIZE(crag6410_devices)); gpio_led_register_device(-1, &gpio_leds_pdata); regulator_has_full_constraints(); s3c64xx_pm_init(); }
int lcd_power_ctrl(s32 value) { int err; if (value) { printk(KERN_INFO "LCD power on sequence start\n"); if (gpio_is_valid(S3C64XX_GPM(3))) { err = gpio_request(S3C64XX_GPM(3), "GPM"); if (err) { printk(KERN_ERR "failed to request GPM for " "lcd reset control\n"); return -1; } gpio_direction_output(S3C64XX_GPM(3), 1); } printk(KERN_INFO "LCD power on sequence end\n"); } else { printk(KERN_INFO "LCD power off sequence start\n"); if (gpio_is_valid(S3C64XX_GPM(3))) { err = gpio_request(S3C64XX_GPM(3), "GPM"); if (err) { printk(KERN_ERR "failed to request GPM for " "lcd reset control\n"); return -1; } gpio_direction_output(S3C64XX_GPM(3), 0); } printk(KERN_INFO "LCD power off sequence end\n"); } gpio_free(S3C64XX_GPM(3)); lcd_power = value; return 0; }
.ngpio = S3C64XX_GPIO_E_NR, .label = "GPE", }, }, { .base = S3C64XX_GPG_BASE, .config = &gpio_4bit_cfg_eint0111, .chip = { .base = S3C64XX_GPG(0), .ngpio = S3C64XX_GPIO_G_NR, .label = "GPG", }, }, { .base = S3C64XX_GPM_BASE, .config = &gpio_4bit_cfg_eint0011, .chip = { .base = S3C64XX_GPM(0), .ngpio = S3C64XX_GPIO_M_NR, .label = "GPM", .to_irq = s3c64xx_gpio2int_gpm, }, }, }; int s3c64xx_gpio2int_gpl(struct gpio_chip *chip, unsigned pin) { return pin >= 8 ? IRQ_EINT(16) + pin - 8 : -ENXIO; } static struct s3c_gpio_chip gpio_4bit2[] = { { .base = S3C64XX_GPH_BASE + 0x4,
static int s3c_irq_eint_set_type(struct irq_data *data, unsigned int type) { int offs = eint_offset(data->irq); int pin, pin_val; int shift; u32 ctrl, mask; u32 newvalue = 0; void __iomem *reg; if (offs > 27) return -EINVAL; if (offs <= 15) reg = S3C64XX_EINT0CON0; else reg = S3C64XX_EINT0CON1; switch (type) { case IRQ_TYPE_NONE: printk(KERN_WARNING "No edge setting!\n"); break; case IRQ_TYPE_EDGE_RISING: newvalue = S3C2410_EXTINT_RISEEDGE; break; case IRQ_TYPE_EDGE_FALLING: newvalue = S3C2410_EXTINT_FALLEDGE; break; case IRQ_TYPE_EDGE_BOTH: newvalue = S3C2410_EXTINT_BOTHEDGE; break; case IRQ_TYPE_LEVEL_LOW: newvalue = S3C2410_EXTINT_LOWLEV; break; case IRQ_TYPE_LEVEL_HIGH: newvalue = S3C2410_EXTINT_HILEV; break; default: printk(KERN_ERR "No such irq type %d", type); return -1; } if (offs <= 15) shift = (offs / 2) * 4; else shift = ((offs - 16) / 2) * 4; mask = 0x7 << shift; ctrl = __raw_readl(reg); ctrl &= ~mask; ctrl |= newvalue << shift; __raw_writel(ctrl, reg); /* set the GPIO pin appropriately */ if (offs < 16) { pin = S3C64XX_GPN(offs); pin_val = S3C_GPIO_SFN(2); } else if (offs < 23) { pin = S3C64XX_GPL(offs + 8 - 16); pin_val = S3C_GPIO_SFN(3); } else { pin = S3C64XX_GPM(offs - 23); pin_val = S3C_GPIO_SFN(3); } s3c_gpio_cfgpin(pin, pin_val); return 0; }
static void smartq_lcd_power_set(struct plat_lcd_data *pd, unsigned int power) { gpio_direction_output(S3C64XX_GPM(3), power); }
{ int ret; ret = gpio_request(S3C64XX_GPM(3), "LCD power"); if (ret < 0) return ret; /* turn power off */ gpio_direction_output(S3C64XX_GPM(3), 0); return 0; } /* GPM0 -> CS */ static struct spi_gpio_platform_data smartq_lcd_control = { .sck = S3C64XX_GPM(1), .mosi = S3C64XX_GPM(2), .miso = S3C64XX_GPM(2), }; static struct platform_device smartq_lcd_control_device = { .name = "spi-gpio", .id = 1, .dev.platform_data = &smartq_lcd_control, }; static void smartq_lcd_power_set(struct plat_lcd_data *pd, unsigned int power) { gpio_direction_output(S3C64XX_GPM(3), power); }
static int s3c_irq_eint_set_type(unsigned int irq, unsigned int type) { int offs = eint_offset(irq); int shift; u32 ctrl, mask; u32 newvalue = 0; void __iomem *reg; if (offs > 27) return -EINVAL; /* fixed by jsgood */ if (offs > 15) reg = S3C64XX_EINT0CON1; /* org: reg = S3C64XX_EINT0CON0; */ else reg = S3C64XX_EINT0CON0; /* org: reg = S3C64XX_EINT0CON1; */ switch (type) { case IRQ_TYPE_NONE: printk(KERN_WARNING "No edge setting!\n"); break; case IRQ_TYPE_EDGE_RISING: newvalue = S3C2410_EXTINT_RISEEDGE; break; case IRQ_TYPE_EDGE_FALLING: newvalue = S3C2410_EXTINT_FALLEDGE; break; case IRQ_TYPE_EDGE_BOTH: newvalue = S3C2410_EXTINT_BOTHEDGE; break; case IRQ_TYPE_LEVEL_LOW: newvalue = S3C2410_EXTINT_LOWLEV; break; case IRQ_TYPE_LEVEL_HIGH: newvalue = S3C2410_EXTINT_HILEV; break; default: printk(KERN_ERR "No such irq type %d", type); return -1; } /* fixed by jsgood */ shift = ((offs % 16) / 2) * 4; /* org: shift = (offs / 2) * 4; */ mask = 0x7 << shift; ctrl = __raw_readl(reg); ctrl &= ~mask; ctrl |= newvalue << shift; __raw_writel(ctrl, reg); if (offs < 16) s3c_gpio_cfgpin(S3C64XX_GPN(offs), 0x2 << (offs * 2)); else if (offs < 23) s3c_gpio_cfgpin(S3C64XX_GPL(offs - 8), S3C_GPIO_SFN(3)); else s3c_gpio_cfgpin(S3C64XX_GPM(offs - 23), S3C_GPIO_SFN(3)); return 0; }
static void __init smartq5_lcd_setup_gpio(void) { gpio_request(S3C64XX_GPM(0), "LCD SCEN pin"); gpio_request(S3C64XX_GPM(1), "LCD SCL pin"); gpio_request(S3C64XX_GPM(2), "LCD SDA pin"); gpio_request(S3C64XX_GPM(3), "LCD power"); /* turn power off */ gpio_direction_output(S3C64XX_GPM(0), 1); gpio_direction_input(S3C64XX_GPM(1)); gpio_direction_input(S3C64XX_GPM(2)); gpio_direction_output(S3C64XX_GPM(3), 0); } static struct i2c_gpio_platform_data smartq5_lcd_control = { .sda_pin = S3C64XX_GPM(2), .scl_pin = S3C64XX_GPM(1), }; static struct platform_device smartq5_lcd_control_device = { .name = "i2c-gpio", .id = 1, .dev.platform_data = &smartq5_lcd_control, }; static struct gpio_led smartq5_leds[] __initdata = { { .name = "smartq5:green", .active_low = 1, .gpio = S3C64XX_GPN(8), },
static int s3c_irq_eint_set_type(unsigned int irq, unsigned int type) { int offs = eint_offset(irq); int pin; int shift; u32 ctrl, mask; u32 newvalue = 0; void __iomem *reg; if (offs > 27) return -EINVAL; if (offs <= 15) reg = S3C64XX_EINT0CON0; else reg = S3C64XX_EINT0CON1; switch (type) { case IRQ_TYPE_NONE: printk(KERN_WARNING "No edge setting!\n"); break; case IRQ_TYPE_EDGE_RISING: newvalue = S3C2410_EXTINT_RISEEDGE; break; case IRQ_TYPE_EDGE_FALLING: newvalue = S3C2410_EXTINT_FALLEDGE; break; case IRQ_TYPE_EDGE_BOTH: newvalue = S3C2410_EXTINT_BOTHEDGE; break; case IRQ_TYPE_LEVEL_LOW: newvalue = S3C2410_EXTINT_LOWLEV; break; case IRQ_TYPE_LEVEL_HIGH: newvalue = S3C2410_EXTINT_HILEV; break; default: printk(KERN_ERR "No such irq type %d", type); return -1; } shift = (offs / 2) * 4; mask = 0x7 << shift; ctrl = __raw_readl(reg); ctrl &= ~mask; ctrl |= newvalue << shift; __raw_writel(ctrl, reg); if (offs < 23) pin = S3C64XX_GPN(offs); else pin = S3C64XX_GPM(offs - 23); s3c_gpio_cfgpin(pin, S3C_GPIO_SFN(2)); return 0; }
static struct platform_device s3c_device_dm9000 = { .name = "dm9000", .id = 0, .num_resources = ARRAY_SIZE(dm9000_resources), .resource = dm9000_resources, .dev = { .platform_data = &dm9000_setup, } }; #endif static struct gpio_led ok6410_leds[] = { [0]= { .name = "LED1", .gpio = S3C64XX_GPM(0), }, [1]= { .name = "LED2", .gpio = S3C64XX_GPM(1), }, [2]= { .name = "LED3", .gpio = S3C64XX_GPM(2), }, [3]= { .name = "LED4", .gpio = S3C64XX_GPM(3), }, };