void pm_do_poweroff(void) { unsigned long start, flags; PWER &= ~0x8000ffff; local_irq_save(flags); printk("Poweroff, Begin to wait BP_RDY signal.\n"); pm_send_all(PM_SUSPEND, (void *)3); start = OSCR; *(unsigned long *)(phys_to_virt(BPSIG_ADDR)) = NO_FLAG; do { if( !(GPLR(GPIO_BP_RDY) & GPIO_bit(GPIO_BP_RDY))){ printk(KERN_DEBUG"got BP_RDY signal.\n"); GPDR(GPIO_WDI_AP) |= GPIO_bit(GPIO_WDI_AP); GPCR(GPIO_WDI_AP) = GPIO_bit(GPIO_WDI_AP); while(1); } if ((OSCR - start) >= POWER_OFF_TIMEOUT) { printk(KERN_DEBUG "timeout when power down\n"); mdelay(1); GPDR(GPIO_WDI_AP) |= GPIO_bit(GPIO_WDI_AP); GPCR(GPIO_WDI_AP) = GPIO_bit(GPIO_WDI_AP); while(1); } } while(1); pm_do_useroff(); printk(KERN_DEBUG "resume from useroff\n"); pm_send_all(PM_SUSPEND, (void *)0); local_irq_restore(flags); }
static int cmx270_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state) { GPSR(GPIO49_nPWE) = GPIO_bit(GPIO49_nPWE); pxa_gpio_mode(GPIO49_nPWE | GPIO_OUT); switch (skt->nr) { case 0: if (state->flags & SS_RESET) { GPCR(GPIO49_nPWE) = GPIO_bit(GPIO49_nPWE); GPSR(GPIO53_nPCE_2) = GPIO_bit(GPIO53_nPCE_2); udelay(10); GPCR(GPIO53_nPCE_2) = GPIO_bit(GPIO53_nPCE_2); GPSR(GPIO49_nPWE) = GPIO_bit(GPIO49_nPWE); } break; case 1: if (state->flags & SS_RESET) { GPCR(GPIO49_nPWE) = GPIO_bit(GPIO49_nPWE); GPSR(GPIO53_nPCE_2) = GPIO_bit(GPIO53_nPCE_2); udelay(10); GPCR(GPIO53_nPCE_2) = GPIO_bit(GPIO53_nPCE_2); GPSR(GPIO49_nPWE) = GPIO_bit(GPIO49_nPWE); } break; } pxa_gpio_mode(GPIO49_nPWE_MD); return 0; }
int dsp_reset(struct inode *inode, struct file *file, unsigned cmd,unsigned long arg) { /* ignore any argument, just do reset here */ /* raise reset */ GPSR(73) |= GPIO_bit(73); /* udelay(1); DAVEDE */ /* wait 1/7.3728MHz = 135.6ns (par 11.13.4) */ /* sleep 1/10 second */ set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(HZ/10); /* Same PIOs of sa1110 */ GPSR(19) |= GPIO_bit(19); GPCR(17) |= GPIO_bit(17); /* sleep 2/10 second */ set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(2*HZ/10); /* lower reset */ GPCR(73) |= GPIO_bit(73); set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(2*HZ/10); writew(DSP_BOB, (unsigned short *)dsp_iopage); // little endian return 0; }
static __init int tdamc_init(void) { int retval=0; printk(KERN_ERR"tdamc_init mc_power=%d (otherwise power up tda for attach only)\n",mc_power); printk(KERN_ERR"btweb_features.abil_dem_video=%d,btweb_features.abil_mod_video=%d\n",btweb_features.abil_dem_video,btweb_features.abil_mod_video); if ( (!mc_power) ){ /* Switching on demodulator only for i2c attach */ GPSR(btweb_features.abil_dem_video) = GPIO_bit(btweb_features.abil_dem_video); slave_address = SLAVE_ADDRESS_TDA; } else{ /* Switching on modulator only for i2c attach */ GPSR(btweb_features.abil_mod_video) = GPIO_bit(btweb_features.abil_mod_video); slave_address = SLAVE_ADDRESS_MC; } normal_addr[0] = slave_address; if(normal_addr[0] >= 0x80) { printk(KERN_ERR"I2C: Invalid slave address for TDA (0x%x)\n", normal_addr[0]); return -EINVAL; } udelay(1000); retval = i2c_add_driver(&tdamc_driver); if (retval) return retval; retval = misc_register (&tdamc_miscdev); if (retval) { i2c_del_driver(&tdamc_driver); return retval; } printk("I2C: TDA9885-MC44BS driver successfully loaded\n"); if ( (!mc_power) ){ /* Switching on demodulator only for i2c attach */ GPCR(btweb_features.abil_dem_video) = GPIO_bit(btweb_features.abil_dem_video); slave_address = SLAVE_ADDRESS_TDA; } else{ /* Switching on modulator only for i2c attach */ GPCR(btweb_features.abil_mod_video) = GPIO_bit(btweb_features.abil_mod_video); slave_address = SLAVE_ADDRESS_MC; } slave_address=0; normal_addr[0] = 0; return 0; }
static void poodle_mci_setpower(struct device *dev, unsigned int vdd) { struct pxamci_platform_data* p_d = dev->platform_data; if (( 1 << vdd) & p_d->ocr_mask) { GPSR(POODLE_GPIO_SD_PWR) = GPIO_bit(POODLE_GPIO_SD_PWR); mdelay(2); GPSR(POODLE_GPIO_SD_PWR1) = GPIO_bit(POODLE_GPIO_SD_PWR1); } else { GPCR(POODLE_GPIO_SD_PWR1) = GPIO_bit(POODLE_GPIO_SD_PWR1); GPCR(POODLE_GPIO_SD_PWR) = GPIO_bit(POODLE_GPIO_SD_PWR); } }
int sg_ssp_open (struct inode *inode, struct file *filp) { MOD_INC_USE_COUNT; GPCR(22) = GPIO_bit(22); // MUX -> Programming mode SSCR0 = ((10 << 8) | SSPC_SSE | 7); /* SRC=3, SSE, DSS = 8-bit data */ /* Put attached mote into reset */ GPCR(77) = GPIO_bit(77); // RSTN -> 0 return 0; }
static void corgi_charge(int on) { if (on) { if (machine_is_corgi() && (sharpsl_pm.flags & SHARPSL_SUSPENDED)) { GPCR(CORGI_GPIO_CHRG_ON) = GPIO_bit(CORGI_GPIO_CHRG_ON); GPSR(CORGI_GPIO_CHRG_UKN) = GPIO_bit(CORGI_GPIO_CHRG_UKN); } else { GPSR(CORGI_GPIO_CHRG_ON) = GPIO_bit(CORGI_GPIO_CHRG_ON); GPCR(CORGI_GPIO_CHRG_UKN) = GPIO_bit(CORGI_GPIO_CHRG_UKN); } } else { GPCR(CORGI_GPIO_CHRG_ON) = GPIO_bit(CORGI_GPIO_CHRG_ON); GPCR(CORGI_GPIO_CHRG_UKN) = GPIO_bit(CORGI_GPIO_CHRG_UKN); } }
static void corgi_measure_temp(int on) { if (on) GPSR(CORGI_GPIO_ADC_TEMP_ON) = GPIO_bit(CORGI_GPIO_ADC_TEMP_ON); else GPCR(CORGI_GPIO_ADC_TEMP_ON) = GPIO_bit(CORGI_GPIO_ADC_TEMP_ON); }
static void corgi_discharge(int on) { if (on) GPSR(CORGI_GPIO_DISCHARGE_ON) = GPIO_bit(CORGI_GPIO_DISCHARGE_ON); else GPCR(CORGI_GPIO_DISCHARGE_ON) = GPIO_bit(CORGI_GPIO_DISCHARGE_ON); }
/* * Irda */ static void corgi_irda_transceiver_mode(struct device *dev, int mode) { if (mode & IR_OFF) GPSR(CORGI_GPIO_IR_ON) = GPIO_bit(CORGI_GPIO_IR_ON); else GPCR(CORGI_GPIO_IR_ON) = GPIO_bit(CORGI_GPIO_IR_ON); }
int pxa_gpio_mode(int gpio_mode) { unsigned long flags; int gpio = gpio_mode & GPIO_MD_MASK_NR; int fn = (gpio_mode & GPIO_MD_MASK_FN) >> 8; int gafr; if (gpio > pxa_last_gpio) return -EINVAL; local_irq_save(flags); if (gpio_mode & GPIO_DFLT_LOW) GPCR(gpio) = GPIO_bit(gpio); else if (gpio_mode & GPIO_DFLT_HIGH) GPSR(gpio) = GPIO_bit(gpio); if (gpio_mode & GPIO_MD_MASK_DIR) GPDR(gpio) |= GPIO_bit(gpio); else GPDR(gpio) &= ~GPIO_bit(gpio); gafr = GAFR(gpio) & ~(0x3 << (((gpio) & 0xf)*2)); GAFR(gpio) = gafr | (fn << (((gpio) & 0xf)*2)); local_irq_restore(flags); return 0; }
static int cmx270_pcmcia_hw_init(struct soc_pcmcia_socket *skt) { GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) | GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) | GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO85_nPCE_1) | GPIO_bit(GPIO54_nPCE_2); pxa_gpio_mode(GPIO48_nPOE_MD); pxa_gpio_mode(GPIO49_nPWE_MD); pxa_gpio_mode(GPIO50_nPIOR_MD); pxa_gpio_mode(GPIO51_nPIOW_MD); pxa_gpio_mode(GPIO85_nPCE_1_MD); pxa_gpio_mode(GPIO54_nPCE_2_MD); pxa_gpio_mode(GPIO55_nPREG_MD); pxa_gpio_mode(GPIO56_nPWAIT_MD); pxa_gpio_mode(GPIO57_nIOIS16_MD); /* Reset signal */ pxa_gpio_mode(GPIO53_nPCE_2 | GPIO_OUT); GPCR(GPIO53_nPCE_2) = GPIO_bit(GPIO53_nPCE_2); set_irq_type(PCMCIA_S0_CD_VALID, IRQ_TYPE_EDGE_BOTH); set_irq_type(PCMCIA_S1_CD_VALID, IRQ_TYPE_EDGE_BOTH); /* irq's for slots: */ set_irq_type(PCMCIA_S0_RDYINT, IRQ_TYPE_EDGE_FALLING); set_irq_type(PCMCIA_S1_RDYINT, IRQ_TYPE_EDGE_FALLING); skt->irq = (skt->nr == 0) ? PCMCIA_S0_RDYINT : PCMCIA_S1_RDYINT; return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs)); }
static void cmx270_green_set(struct led_classdev *led_cdev, enum led_brightness value) { if (value) GPCR(GPIO_GREEN_LED) = GPIO_bit(GPIO_GREEN_LED); else GPSR(GPIO_GREEN_LED) = GPIO_bit(GPIO_GREEN_LED); }
void pxa_gpio_set(int gpio, int on) { if (on) GPSR(gpio) = GPIO_BIT(gpio); else GPCR(gpio) = GPIO_BIT(gpio); }
/* * Irda */ static void poodle_irda_transceiver_mode(struct device *dev, int mode) { if (mode & IR_OFF) { GPSR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON); } else { GPCR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON); } }
static void gpio_set(int id, int on) { do { if (on) GPSR(id) = GPIO_bit(id); else GPCR(id) = GPIO_bit(id); } while (0); }
static __exit void tdamc_exit(void) { misc_deregister(&tdamc_miscdev); i2c_del_driver(&tdamc_driver); printk("tdamc9885_mc44bs.c: Switching off mod/demod power\n"); /* Switching off mod and demod*/ // if (tda_power) { GPCR(btweb_features.abil_dem_video) = GPIO_bit(btweb_features.abil_dem_video); // } // if (mc_power) { GPCR(btweb_features.abil_mod_video) = GPIO_bit(btweb_features.abil_mod_video); // } }
void turn_off_gpio(int gpio) { set_GPIO_mode(gpio | GPIO_OUT); GPCR(gpio) = GPIO_bit(gpio); if (GPLR(gpio) & GPIO_bit(gpio)) { PDEBUG("LED gpio %d on\n", gpio); } else { PDEBUG("LED gpio %d off\n", gpio); } }
static void snd_h4000_audio_set_codec_reset(int mode) { if (mode == 1) { DPM_DEBUG("h4000_audio: Codec reset on\n"); GPSR(GPIO_NR_H4000_CODEC_RST) = GPIO_bit(GPIO_NR_H4000_CODEC_RST); } else { DPM_DEBUG("h4000_audio: Codec reset off\n"); GPCR(GPIO_NR_H4000_CODEC_RST) = GPIO_bit(GPIO_NR_H4000_CODEC_RST); } }
static int tdamc_ioctl( struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { switch (cmd) { default: case 5500: tda_power=1; GPSR(btweb_features.abil_dem_video) = GPIO_bit(btweb_features.abil_dem_video); slave_address = SLAVE_ADDRESS_TDA; normal_addr[0] = slave_address; printk("tda9885_mc44bs: tda9885 registered and selected tda \n"); tdamc_i2c_client->addr=slave_address; break; case 5501: mc_power=1; GPSR(btweb_features.abil_mod_video) = GPIO_bit(btweb_features.abil_mod_video); slave_address = SLAVE_ADDRESS_MC; normal_addr[0] = slave_address; printk("tda9885_mc44bs: tda9885 registered and selected mc \n"); tdamc_i2c_client->addr=slave_address; break; case 5502: printk("tdamc9885_mc44bs.c: Switching off mod/demod power\n"); // if (tda_power) { GPCR(btweb_features.abil_dem_video) = GPIO_bit(btweb_features.abil_dem_video); // } // if (mc_power) { GPCR(btweb_features.abil_mod_video) = GPIO_bit(btweb_features.abil_mod_video); // } slave_address=0; mc_power=0; tda_power=0; normal_addr[0] = slave_address; break; } return 0; }
void btweb_backlight(int onoff) { int btsys_lcd = onoff; if (btsys_lcd) GPSR(12) = GPIO_bit(12); else GPCR(12) = GPIO_bit(12); }
ssize_t gpio_write(struct file *file, const char *ubuf, size_t count, loff_t *offp) { unsigned int domode=0, inout=0, i, j; char buf[16]; char *p; if (count > 15) count = 15; if (copy_from_user(buf, ubuf, count)) return -EFAULT; buf[count] = '\0'; p = buf; /* skip blanks: it may be all blanks, then accept it */ while (*p && isspace(*p)) p++; if (!*p) return count; /* mode: accept M and I or O */ if (*p == 'm' || *p == 'M') { domode++, p++; if (*p == 'i' || *p == 'I') inout= 0; else if (*p == 'o' || *p == 'O') inout = GPIO_MD_MASK_DIR; else return -EINVAL; p++; } /* get numbers */ if (sscanf(p, "%i=%i", &i, &j) != 2) return -EINVAL; if (!i || i > 80 || j > 3) return -EINVAL; if (!domode && j > 1) return -EINVAL; /* act */ if (domode) { if (!j) domode = 0; if (j == 1) domode = GPIO_ALT_FN_1_IN; if (j == 2) domode = GPIO_ALT_FN_2_IN; if (j == 3) domode = GPIO_ALT_FN_3_IN; domode |= inout; set_GPIO_mode( i | domode); } else { if (j) GPSR(i) = GPIO_bit(i); else GPCR(i) = GPIO_bit(i); } *offp += count; return count; }
static int dot_reset(void){ GPCR(DOT_RESET) |= GPIO_bit(DOT_RESET); GPSR(DOT_RESET) |= GPIO_bit(DOT_RESET); /* DOT_COL_1 = 0x00; DOT_COL_2 = 0x00; DOT_COL_3 = 0x00; DOT_COL_4 = 0x00; DOT_COL_5 = 0x00; */ return 0; }
/* * USB Device Controller */ static void poodle_udc_command(int cmd) { switch(cmd) { case PXA2XX_UDC_CMD_CONNECT: GPSR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP); break; case PXA2XX_UDC_CMD_DISCONNECT: GPCR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP); break; } }
/* * USB Device Controller */ static void corgi_udc_command(int cmd) { switch(cmd) { case PXA2XX_UDC_CMD_CONNECT: GPSR(CORGI_GPIO_USB_PULLUP) = GPIO_bit(CORGI_GPIO_USB_PULLUP); break; case PXA2XX_UDC_CMD_DISCONNECT: GPCR(CORGI_GPIO_USB_PULLUP) = GPIO_bit(CORGI_GPIO_USB_PULLUP); break; } }
/* Disconnect the USB device to the bus */ void udc_disconnect(void) { usbdbg("UDC disconnect"); #ifdef CONFIG_USB_DEV_PULLUP_GPIO /* Turn off the USB connection by disabling the pullup resistor */ writel(GPIO_bit(CONFIG_USB_DEV_PULLUP_GPIO), GPCR(CONFIG_USB_DEV_PULLUP_GPIO)); #else /* Host port 2 transceiver D+ pull up disable */ writel(readl(UP2OCR) & ~UP2OCR_DPPUE, UP2OCR); #endif }
static void clear_douts(unsigned char bits) { #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35) GPCR(20) = (u32)bits << 20; #else int i; unsigned char m = 1; for (i=0; i < 8; i++,m<<=1) { if (bits & m) gpio_set_value(VIPER_PL9_OUT0 + i,0); } #endif }
static void cmx270_mci_setpower(struct device *dev, unsigned int vdd) { struct pxamci_platform_data *p_d = dev->platform_data; if ((1 << vdd) & p_d->ocr_mask) { printk(KERN_DEBUG "%s: on\n", __FUNCTION__); GPCR(105) = GPIO_bit(105); } else { GPSR(105) = GPIO_bit(105); printk(KERN_DEBUG "%s: off\n", __FUNCTION__); } }
static void alpine_gsm_reset(void) { printk ("GSM Reset\n"); GPSR(36) = GPIO_bit(36); pxa_gpio_mode(36 | GPIO_OUT); pxa_gpio_mode (10 | GPIO_IN); pxa_gpio_mode (108 | GPIO_IN); asic5_egpio_set_value(0, 0); /* DTR? */ asic5_egpio_set_value(11, 0); /* magician: pxa gpio 11 */ GPCR(87) = GPIO_bit(87); /* stop display to avoid interference? */ GPCR(GPIO74_LCD_FCLK) = GPIO_bit(GPIO74_LCD_FCLK); htcalpine_cpld_egpio_set_value(15, 1); /* GSM_POWER */ asic5_egpio_set_value(22, 1); /* ?? */ msleep (150); GPSR(GPIO74_LCD_FCLK) = GPIO_bit(GPIO74_LCD_FCLK); msleep (150); GPCR(GPIO74_LCD_FCLK) = GPIO_bit(GPIO74_LCD_FCLK); asic5_egpio_set_value(11, 1); /* FIXME: disable+reenable 86, is this OK? */ GPCR(86) = GPIO_bit(86); // ?? GPSR(86) = GPIO_bit(86); // GSM_RESET asic5_egpio_set_value(9, 1); /* magician: pxa gpio 26 */ msleep(150); GPCR(86) = GPIO_bit(86); msleep(10); pxa_gpio_mode(36 | GPIO36_FFDCD_MD); /* or just GPIO_IN? */ asic5_phone_on(); }
static void pxa2xx_mfp_resume(void) { int i; for (i = 0; i <= gpio_to_bank(pxa_last_gpio); i++) { GAFR_L(i) = saved_gafr[0][i]; GAFR_U(i) = saved_gafr[1][i]; GPSR(i * 32) = saved_gplr[i]; GPCR(i * 32) = ~saved_gplr[i]; GPDR(i * 32) = saved_gpdr[i]; PGSR(i) = saved_pgsr[i]; } PSSR = PSSR_RDH | PSSR_PH; }