/* * Routine: setup_net_chip * Description: Setting up the configuration GPMC registers specific to the * Ethernet hardware. */ static void setup_net_chip(void) { struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE; /* Configure GPMC registers */ writel(NET_LAN9221_GPMC_CONFIG1, &gpmc_cfg->cs[5].config1); writel(NET_LAN9221_GPMC_CONFIG2, &gpmc_cfg->cs[5].config2); writel(NET_LAN9221_GPMC_CONFIG3, &gpmc_cfg->cs[5].config3); writel(NET_LAN9221_GPMC_CONFIG4, &gpmc_cfg->cs[5].config4); writel(NET_LAN9221_GPMC_CONFIG5, &gpmc_cfg->cs[5].config5); writel(NET_LAN9221_GPMC_CONFIG6, &gpmc_cfg->cs[5].config6); writel(NET_LAN9221_GPMC_CONFIG7, &gpmc_cfg->cs[5].config7); /* Enable off mode for NWE in PADCONF_GPMC_NWE register */ writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe); /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */ writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe); /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */ writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00, &ctrl_base->gpmc_nadv_ale); /* Make GPIO 64 as output pin and send a magic pulse through it */ if (!omap_request_gpio(64)) { omap_set_gpio_direction(64, 0); omap_set_gpio_dataout(64, 1); udelay(1); omap_set_gpio_dataout(64, 0); udelay(1); omap_set_gpio_dataout(64, 1); } }
/** * Reset the ethernet chip. */ static void reset_net_chip(void) { int ret; int rst_gpio; if (get_omap3_evm_rev() == OMAP3EVM_BOARD_GEN_1) { rst_gpio = OMAP3EVM_GPIO_ETH_RST_GEN1; } else { rst_gpio = OMAP3EVM_GPIO_ETH_RST_GEN2; } ret = omap_request_gpio(rst_gpio); if (ret < 0) { printf("Unable to get GPIO %d\n", rst_gpio); return ; } /* Configure as output */ omap_set_gpio_direction(rst_gpio, 0); /* Send a pulse on the GPIO pin */ omap_set_gpio_dataout(rst_gpio, 1); udelay(1); omap_set_gpio_dataout(rst_gpio, 0); udelay(1); omap_set_gpio_dataout(rst_gpio, 1); }
/* * Enable or disable power to TUSB6010. When enabling, turn on 3.3 V and * 1.5 V voltage regulators of PM companion chip. Companion chip will then * provide then PGOOD signal to TUSB6010 which will release it from reset. */ static int tusb_set_power(int state) { int i, retval = 0; if (state) { omap_set_gpio_dataout(GPIO_TUSB_ENABLE, 1); msleep(1); /* Wait until TUSB6010 pulls INT pin down */ i = 100; while (i && omap_get_gpio_datain(GPIO_TUSB_INT)) { msleep(1); i--; } if (!i) { printk(KERN_ERR "tusb: powerup failed\n"); retval = -ENODEV; } } else { omap_set_gpio_dataout(GPIO_TUSB_ENABLE, 0); msleep(10); } return retval; }
static void setup_net_chip(void) { struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE; enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5], 0x2C000000, GPMC_SIZE_16M); /* Enable off mode for NWE in PADCONF_GPMC_NWE register */ writew(readw(&ctrl_base->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe); /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */ writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe); /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */ writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00, &ctrl_base->gpmc_nadv_ale); /* Make GPIO 64 as output pin and send a magic pulse through it */ if (!omap_request_gpio(64)) { omap_set_gpio_direction(64, 0); omap_set_gpio_dataout(64, 1); udelay(1); omap_set_gpio_dataout(64, 0); udelay(1); omap_set_gpio_dataout(64, 1); } }
static int panel_init(struct omap_display_data *ddata) { pr_debug("panel_init [%s]\n", ddata->panel_name); GPIO_INIT_OUTPUT(display_gpio.lcd_pwon); GPIO_INIT_OUTPUT(display_gpio.lcd_rst); GPIO_INIT_OUTPUT(display_gpio.lcd_pci); GPIO_INIT_OUTPUT(display_gpio.disp_select); GPIO_INIT_OUTPUT(display_gpio.cpldreset); #if !defined(CONFIG_FB_OMAP_BOOTLOADER_INIT) if (GPIO_EXISTS(display_gpio.lcd_pwon)) omap_set_gpio_dataout( GPIO_PIN(display_gpio.lcd_pwon), 0); if (GPIO_EXISTS(display_gpio.lcd_rst)) omap_set_gpio_dataout( GPIO_PIN(display_gpio.lcd_rst), 0); if (GPIO_EXISTS(display_gpio.lcd_pci)) omap_set_gpio_dataout( GPIO_PIN(display_gpio.lcd_pci), 0); /* reset and enable the CPLD */ if (GPIO_EXISTS(display_gpio.cpldreset)) omap_set_gpio_dataout( GPIO_PIN(display_gpio.cpldreset), 0); mdelay(2); if (GPIO_EXISTS(display_gpio.cpldreset)) omap_set_gpio_dataout( GPIO_PIN(display_gpio.cpldreset), 1); #endif return 0; }
/* * Routine: get_sdio2_config * Description: Return information about the wifi module connection * Returns 0 if the module connects though a level translator * Returns 1 if the module connects directly */ int get_sdio2_config(void) { int sdio_direct; if (!omap_request_gpio(130) && !omap_request_gpio(139)) { omap_set_gpio_direction(130, 0); omap_set_gpio_direction(139, 1); sdio_direct = 1; omap_set_gpio_dataout(130, 0); if (omap_get_gpio_datain(139) == 0) { omap_set_gpio_dataout(130, 1); if (omap_get_gpio_datain(139) == 1) sdio_direct = 0; } omap_free_gpio(130); omap_free_gpio(139); } else { printf("Error: unable to acquire sdio2 clk GPIOs\n"); sdio_direct=-1; } return sdio_direct; }
/* export usbsata_power to drivers for power management */ void usbsata_power(int on_off) { if (satavcc == on_off) return; printk("usbsata_power %i\n", on_off); satavcc = on_off; if (on_off) { omap_set_gpio_dataout(GPIO_PIN(gpio_hdd_pwron), on_off); msleep(100); #ifdef DELAY_500GB_SEAGATE msleep(400); #endif omap_set_gpio_dataout(GPIO_PIN(gpio_sata_pwron), on_off); #ifdef DELAY_500GB_SEAGATE msleep(500); #endif //clk_enable(clkout1); //archos_enable_ehci( 1 ); } else { omap_set_gpio_dataout(GPIO_PIN(gpio_hdd_pwron), on_off); omap_set_gpio_dataout(GPIO_PIN(gpio_sata_pwron), on_off); /* wait another 100ms to propagate the disconnect through * the phy, then switch if off */ //msleep(100); //archos_enable_ehci( 0 ); //clk_disable(clkout1); } }
static void palmte_pin_handler(unsigned long data) { int power, headphones; power = !omap_get_gpio_datain(PALMTE_DC_GPIO); headphones = omap_get_gpio_datain(PALMTE_HEADPHONES_GPIO); if (power && !prev_power) printk(KERN_INFO "PM: cable connected\n"); else if (!power && prev_power) printk(KERN_INFO "PM: cable disconnected\n"); if (headphones && !prev_headphones) { /* Headphones connected, disable speaker */ omap_set_gpio_dataout(PALMTE_SPEAKER_GPIO, 0); printk(KERN_INFO "PM: speaker off\n"); } else if (!headphones && prev_headphones) { /* Headphones unplugged, re-enable speaker */ omap_set_gpio_dataout(PALMTE_SPEAKER_GPIO, 1); printk(KERN_INFO "PM: speaker on\n"); } prev_power = power; prev_headphones = headphones; mod_timer(&palmte_pin_timer, jiffies + msecs_to_jiffies(500)); }
static int omap3evm_panel_init(struct lcd_panel *panel, struct omapfb_device *fbdev) { omap_request_gpio(LCD_PANEL_LR); omap_request_gpio(LCD_PANEL_UD); omap_request_gpio(LCD_PANEL_INI); omap_request_gpio(LCD_PANEL_RESB); omap_request_gpio(LCD_PANEL_QVGA); omap_set_gpio_direction(LCD_PANEL_LR, 0); omap_set_gpio_direction(LCD_PANEL_UD, 0); omap_set_gpio_direction(LCD_PANEL_INI, 0); omap_set_gpio_direction(LCD_PANEL_RESB, 0); omap_set_gpio_direction(LCD_PANEL_QVGA, 0); twl4030_i2c_write_u8(TWL4030_MODULE_LED, 0x11, TWL_LED_LEDEN); twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, 0x01, TWL_PWMA_PWMAON); twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, 0x02, TWL_PWMA_PWMAOFF); bklight_level = 100; omap_set_gpio_dataout(LCD_PANEL_RESB, 1); omap_set_gpio_dataout(LCD_PANEL_INI, 1); omap_set_gpio_dataout(LCD_PANEL_QVGA, 0); omap_set_gpio_dataout(LCD_PANEL_LR, 1); omap_set_gpio_dataout(LCD_PANEL_UD, 1); return 0; }
// LCD configuration // static void lcd_config(void) { u32 ident_lcd = 0; ident_lcd |= 1; printf("LCD panel %x: %s\n", ident_lcd, (ident_lcd == 0)?"WINTEK 4.3 controlled via 3-wire": (ident_lcd == 1)?"S070WV95 7\"": (ident_lcd == 2)?"Dastek 4.3":"unknown"); ident_lcd += 'A'; set_lcd_env(ident_lcd); omap_request_gpio(164); // power on display buffer omap_request_gpio(104); // enable display buffer omap_set_gpio_dataout(164, 1); omap_set_gpio_direction(164, 0); omap_set_gpio_dataout(104, 0); omap_set_gpio_direction(104, 0); omap_free_gpio(104); omap_free_gpio(164); drv_lcd_init(); // initialize LCD interface printf("%s: done\n", __func__); }
static int innovator1610_panel_enable(struct lcd_panel *panel) { /* set GPIO14 and GPIO15 high */ omap_set_gpio_dataout(14, 1); omap_set_gpio_dataout(15, 1); return 0; }
static int sdp2430_panel_enable(struct lcd_panel *panel) { u8 ded_val, ded_reg; u8 grp_val, grp_reg; if (machine_is_omap_3430sdp()) { ded_reg = TWL4030_VAUX3_DEDICATED; ded_val = ENABLE_VAUX3_DEDICATED; grp_reg = TWL4030_VAUX3_DEV_GRP; grp_val = ENABLE_VAUX3_DEV_GRP; } else { ded_reg = TWL4030_VAUX2_DEDICATED; ded_val = ENABLE_VAUX2_DEDICATED; grp_reg = TWL4030_VAUX2_DEV_GRP; grp_val = ENABLE_VAUX2_DEV_GRP; } omap_set_gpio_dataout(enable_gpio, 1); omap_set_gpio_dataout(backlight_gpio, 1); if (0 != t2_out(PM_RECEIVER, ded_val, ded_reg)) return -EIO; if (0 != t2_out(PM_RECEIVER, grp_val, grp_reg)) return -EIO; return 0; }
int __init archos_usb2sata_init(void) { int ret; const struct archos_sata_config *sata_cfg; sata_cfg = omap_get_config( ARCHOS_TAG_SATA, struct archos_sata_config ); if (sata_cfg == NULL) { printk(KERN_DEBUG "archos_sata_init: no board configuration found\n"); return -ENODEV; } if (hardware_rev >= sata_cfg->nrev) { printk(KERN_DEBUG "archos_sata_init: hardware_rev (%i) >= nrev (%i)\n", hardware_rev, sata_cfg->nrev); return -ENODEV; } printk(KERN_DEBUG "archos_usb2sata_init\n"); clkout1 = clk_get(NULL, "sys_clkout1"); if (IS_ERR(clkout1)) { printk(KERN_ERR "clk_get(sys_clkout1) failed\n"); return PTR_ERR(clkout1); } /* sysfs setup */ ret = platform_device_register(&usb2sata_device); if (ret) return ret; /* SATA bridge */ gpio_sata_pwron = sata_cfg->rev[hardware_rev].sata_power; ret = device_create_file(&usb2sata_device.dev, &dev_attr_satavcc); if (ret == 0) { printk(KERN_DEBUG "archos_usb2sata_init: sata_pwron on GPIO%i\n", GPIO_PIN(gpio_sata_pwron)); GPIO_INIT_OUTPUT(gpio_sata_pwron); omap_set_gpio_dataout(GPIO_PIN(gpio_sata_pwron), 0); } /* HDD power switch */ gpio_hdd_pwron = sata_cfg->rev[hardware_rev].hdd_power; printk(KERN_DEBUG "archos_usb2sata_init: sata_pwron on GPIO%i\n", GPIO_PIN(gpio_hdd_pwron)); GPIO_INIT_OUTPUT(gpio_hdd_pwron); omap_set_gpio_dataout(GPIO_PIN(gpio_hdd_pwron), 0); /* SATA_RDY signal */ gpio_sata_rdy = sata_cfg->rev[hardware_rev].sata_ready; ret = device_create_file(&usb2sata_device.dev, &dev_attr_satardy); if (ret == 0) { printk(KERN_DEBUG "archos_usb2sata_init: sata_ready on GPIO%i\n", GPIO_PIN(gpio_sata_rdy)); GPIO_INIT_INPUT(gpio_sata_rdy); } clk_enable(clkout1); usbsata_power(0); return 0; }
static int panel_enable(struct omap_display *disp) { pr_debug("panel_enable [%s]\n", disp->panel->name); omap_set_gpio_dataout(GPIO_PIN(extdac_platform_data.hdmi_dac), 0); omap_set_gpio_dataout(GPIO_PIN(extdac_platform_data.disp_sel), 0); return 0; }
static int h2_transceiver_mode(struct device *dev, int state) { if (state & IR_SIRMODE) omap_set_gpio_dataout(H2_IRDA_FIRSEL_GPIO_PIN, 0); else /* MIR/FIR */ omap_set_gpio_dataout(H2_IRDA_FIRSEL_GPIO_PIN, 1); return 0; }
static void innovator1610_panel_disable(void) { DBGENTER(1); /* set GPIO13, GPIO14 and GPIO15 low */ omap_set_gpio_dataout(14, 0); omap_set_gpio_dataout(15, 0); DBGLEAVE(1); }
static void set_col_gpio_val(struct omap_kp *omap_kp, u8 value) { int col; for (col = 0; col < omap_kp->cols; col++) { if (value & (1 << col)) omap_set_gpio_dataout(col_gpios[col], 1); else omap_set_gpio_dataout(col_gpios[col], 0); } }
static u8 _cbus_receive_bit(struct cbus_host *host) { u8 ret; omap_set_gpio_dataout(host->clk_gpio, 1); ret = omap_get_gpio_datain(host->dat_gpio); omap_set_gpio_dataout(host->clk_gpio, 0); return ret; }
int archos_set_usb_id( int enable ) { if (GPIO_EXISTS(gpio_usb_id)) { if (enable) omap_set_gpio_dataout( GPIO_PIN( gpio_usb_id ), 1); else omap_set_gpio_dataout( GPIO_PIN( gpio_usb_id ), 0); } return 0; }
static void _cbus_send_bit(struct cbus_host *host, int bit, int set_to_input) { omap_set_gpio_dataout(host->dat_gpio, bit ? 1 : 0); omap_set_gpio_dataout(host->clk_gpio, 1); /* The data bit is read on the rising edge of CLK */ if (set_to_input) omap_set_gpio_direction(host->dat_gpio, 1); omap_set_gpio_dataout(host->clk_gpio, 0); }
static void palmte_headphones_detect(void *data, int state) { if (state) { /* Headphones connected, disable speaker */ omap_set_gpio_dataout(PALMTE_SPEAKER_GPIO, 0); printk(KERN_INFO "PM: speaker off\n"); } else { /* Headphones unplugged, re-enable speaker */ omap_set_gpio_dataout(PALMTE_SPEAKER_GPIO, 1); printk(KERN_INFO "PM: speaker on\n"); } }
static int innovator1610_panel_enable(void) { DBGENTER(1); /* set GPIO14 and GPIO15 high */ omap_set_gpio_dataout(14, 1); omap_set_gpio_dataout(15, 1); DBGLEAVE(1); return 0; }
void init_board_gpios() { /* Leave tvp5150 enable and reset pins in a consistent state */ omap_request_gpio(163); omap_request_gpio(164); omap_set_gpio_direction(163,0); omap_set_gpio_direction(164,0); omap_set_gpio_dataout(163,1); omap_set_gpio_dataout(164,0); return; }
static void omap_set_led_gpio(struct led_classdev *led_cdev, enum led_brightness value) { struct omap_led_config *led_dev; led_dev = container_of(led_cdev, struct omap_led_config, cdev); if (value) omap_set_gpio_dataout(led_dev->gpio, 1); else omap_set_gpio_dataout(led_dev->gpio, 0); }
void gpio_on_off(int gpio,char is_on) { omap_request_gpio(gpio); omap_set_gpio_direction(gpio,0); if(is_on) omap_set_gpio_dataout(gpio,1); else omap_set_gpio_dataout(gpio,0); omap_free_gpio(gpio); }
static irqreturn_t apollon_sw_interrupt(int irq, void *ignored, struct pt_regs *regs) { static unsigned int led0, led1, led2; if (irq == OMAP_GPIO_IRQ(SW_ENTER_GPIO16)) omap_set_gpio_dataout(LED0_GPIO13, led0 ^= 1); else if (irq == OMAP_GPIO_IRQ(SW_UP_GPIO17)) omap_set_gpio_dataout(LED1_GPIO14, led1 ^= 1); else if (irq == OMAP_GPIO_IRQ(SW_DOWN_GPIO58)) omap_set_gpio_dataout(LED2_GPIO15, led2 ^= 1); return IRQ_HANDLED; }
int archos_enable_ehci( int enable ) { if ( GPIO_EXISTS( gio_ehci_enable ) ) { if ( enable ) omap_set_gpio_dataout( GPIO_PIN( gio_ehci_enable ), 1); else omap_set_gpio_dataout( GPIO_PIN( gio_ehci_enable ), 0); } ehci_phy_enable = enable; return 0; }
static int panel_set_backlight_level( struct omap_display *disp, int level) { int hw_level; pr_debug("panel_set_backlight_level [%s] %d\n", disp != NULL ? disp->panel->name: "cpt_wvga_48", level); /* skip if panel is not on */ if (panel_state == 0) { saved_bkl_level = level; return 0; } /* clamp the level */ if (level < 0) level = 0; if (level > 255) level = 255; /* nothing to do if levels are equal */ if (bkl_level == level) return 0; /* stop backlight? */ if (level == 0) { if (GPIO_EXISTS(display_gpio.bkl_pwon)) omap_set_gpio_dataout(GPIO_PIN(display_gpio.bkl_pwon), 0); omap_dm_timer_stop(bkl_pwm); omap_dm_timer_disable(bkl_pwm); bkl_level = 0; return 0; } /* start backlight? */ if (bkl_level == 0) { omap_dm_timer_enable(bkl_pwm); omap_dm_timer_set_pwm(bkl_pwm, 0, 1, 2); omap_dm_timer_start(bkl_pwm); if (GPIO_EXISTS(display_gpio.bkl_pwon)) omap_set_gpio_dataout(GPIO_PIN(display_gpio.bkl_pwon), 1); } /* set new level, g7 machines have inverted level */ hw_level = level; if (!machine_is_archos_g6h()) hw_level = 255 - level; pwm_set_speed(bkl_pwm, 10000, hw_level); bkl_level = level; return 0; }
static void mistral_setled(void) { int red = 0; int green = 0; if (hw_led_state & TIMER_LED) red = 1; else if (hw_led_state & IDLE_LED) green = 1; // else both sides are disabled omap_set_gpio_dataout(GPIO_LED_GREEN, green); omap_set_gpio_dataout(GPIO_LED_RED, red); }
void dp3t_switch_ctrl(DP3T_MODE_TYPE mode) { omap_set_gpio_direction(UART_SW1_GPIO, 0); omap_set_gpio_direction(UART_SW2_GPIO, 0); if (mode == DP3T_S1_AP_UART) { ifx_vbus_ctrl(0); omap_set_gpio_dataout(UART_SW1_GPIO, 1); omap_set_gpio_dataout(UART_SW2_GPIO, 0); } else if (mode == DP3T_S2_CP_UART) { ifx_vbus_ctrl(0); omap_set_gpio_dataout(UART_SW1_GPIO, 0); omap_set_gpio_dataout(UART_SW2_GPIO, 1); } else if (mode == DP3T_S3_CP_USB) { ifx_vbus_ctrl(1); omap_set_gpio_dataout(UART_SW1_GPIO, 1); omap_set_gpio_dataout(UART_SW2_GPIO, 1); } else { ifx_vbus_ctrl(0); omap_set_gpio_dataout(UART_SW1_GPIO, 0); omap_set_gpio_dataout(UART_SW2_GPIO, 0); } dp3t_mode = mode; }