static int AVL6211_Reset(int reset_gpio) { gpio_out(reset_gpio, 0); msleep(300); gpio_out(reset_gpio, 1); return 0; }
// ********************* LOW-LEVEL ISSP SUBROUTINE SECTION ******************** // **************************************************************************** // **** PROCESSOR SPECIFIC **** // **************************************************************************** // **** USER ATTENTION REQUIRED **** // **************************************************************************** // ApplyTargetVDD() // Provide power to the target PSoC's Vdd pin through a GPIO. // **************************************************************************** void ApplyTargetVDD(void) { #if 0 gpio_tlmm_config(LED_26V_EN); gpio_tlmm_config(EXT_TSP_SCL); gpio_tlmm_config(EXT_TSP_SDA); gpio_tlmm_config(LED_RST); gpio_out(LED_RST, GPIO_LOW_VALUE); clk_busy_wait(10); gpio_out(LED_26V_EN, GPIO_HIGH_VALUE); #endif gpio_direction_input(_3_TOUCH_SDA_28V); gpio_direction_input(_3_TOUCH_SCL_28V); gpio_direction_output(_3_GPIO_TOUCH_EN, 1); mdelay(1); // for(temp=0; temp < 16;temp++) { // clk_busy_wait(1000); // gave the more delay, changed the LDO // dog_kick(); // } }
static void backlight_power_ctrl(Bool_t status) { PRINT_INFO("%s(): bl_status=%s, data_status=%s, bl_level=%u\n", __FUNCTION__, (bl_status ? "ON" : "OFF"), (data_status ? "ON" : "OFF"), bl_level); if( status == ON ){ if ((bl_status == ON) || (data_status == OFF) || (bl_level == 0)) return; aml_set_reg32_bits(P_LED_PWM_REG0, 1, 12, 2); mdelay(20); #if (BL_CTL==BL_CTL_GPIO) //BL_EN -> GPIOD_1: 1 gpio_out(PAD_GPIOD_1, 1); #elif (BL_CTL==BL_CTL_PWM) aml_set_reg32_bits(P_PWM_MISC_REG_CD, PWM_PRE_DIV, 16, 7); aml_set_reg32_bits(P_PWM_MISC_REG_CD, 1, 23, 1); aml_set_reg32_bits(P_PWM_MISC_REG_CD, 1, 1, 1); //enable pwm_d aml_write_reg32(P_PERIPHS_PIN_MUX_2, aml_read_reg32(P_PERIPHS_PIN_MUX_2) | (1<<3)); //enable pwm pinmux #endif } else{ if (bl_status == OFF) return; #if (BL_CTL==BL_CTL_GPIO) gpio_out(PAD_GPIOD_1, 0); #elif (BL_CTL==BL_CTL_PWM) aml_set_reg32_bits(P_PWM_MISC_REG_CD, 0, 1, 1); //disable pwm_d #endif } bl_status = status; printk(KERN_INFO "%s() Power %s\n", __FUNCTION__, (status ? "ON" : "OFF")); }
int gpio_out_status(char *name,int bit,uint32_t ghigh) { bool high; uint32_t pin; char cmd[10]; sprintf(cmd,"GPIO%s_%d",name,bit); pin = get_pin_num(cmd); printk(KERN_DEBUG "cmd=%s pin = %d ghigh = %d\n",cmd,pin,ghigh); if(pin != -1){ if(ghigh == 1){ high = true; return gpio_out(pin,high); } else if(ghigh == 0){ high = false; return gpio_out(pin,high); } else if(ghigh == -1) { return gpio_get_val(pin); } else{ printk(KERN_ERR "enter error!\n"); } } else{ printk(KERN_ERR "you input error!\n"); return -1; } return 0; }
int main(void) { int i; gpio_t leds = BASE_LEDS_ADDR; gpio_t buttons = BASE_BUTTONS_ADDR; while (1) { /* Rotate the LEDs */ for (i = 0; i < 8; ++i) { // Set led at position i gpio_out(leds, i, 1); //*leds = 1 << i; /* Each loop iteration takes 4 cycles. * It runs at 100MHz. * Sleep 0.2 second. */ delay(LED_DELAY); //for (j = 0; j < 100000000/4/5; ++j) { //asm("# noop"); /* no-op the compiler can't optimize away */ // Clear led at position i gpio_out(leds, i, 0); } } }
bool mcspi_open(Mcspi_t *McspiStruct) { McspiStruct->Gpio_Miso = gpio_assign(McspiStruct->MisoPort, McspiStruct->MisoPin, GPIO_IN_PULL_UP, false); McspiStruct->Gpio_Mosi = gpio_assign(McspiStruct->MosiPort, McspiStruct->MosiPin, GPIO_OUT_PUSH_PULL, false); McspiStruct->Gpio_Sck = gpio_assign(McspiStruct->SckPort, McspiStruct->SckPin, GPIO_OUT_PUSH_PULL, false); if(McspiStruct->CsPort[0] != 0 && McspiStruct->CsPin[0] != 0) { _gpio_init(McspiStruct->CsPort[0]); McspiStruct->Gpio_Cs[0] = gpio_assign(McspiStruct->CsPort[0], McspiStruct->CsPin[0], GPIO_OUT_PUSH_PULL, false); gpio_out(McspiStruct->Gpio_Cs[0], 1); } if(McspiStruct->CsPort[1] != 0 && McspiStruct->CsPin[1] != 0) { _gpio_init(McspiStruct->CsPort[1]); McspiStruct->Gpio_Cs[1] = gpio_assign(McspiStruct->CsPort[1], McspiStruct->CsPin[1], GPIO_OUT_PUSH_PULL, false); gpio_out(McspiStruct->Gpio_Cs[1], 1); } if(McspiStruct->CsPort[2] != 0 && McspiStruct->CsPin[2] != 0) { _gpio_init(McspiStruct->CsPort[2]); McspiStruct->Gpio_Cs[2] = gpio_assign(McspiStruct->CsPort[2], McspiStruct->CsPin[2], GPIO_OUT_PUSH_PULL, false); gpio_out(McspiStruct->Gpio_Cs[2], 1); } if(McspiStruct->CsPort[3] != 0 && McspiStruct->CsPin[3] != 0) { _gpio_init(McspiStruct->CsPort[3]); McspiStruct->Gpio_Cs[3] = gpio_assign(McspiStruct->CsPort[3], McspiStruct->CsPin[3], GPIO_OUT_PUSH_PULL, false); gpio_out(McspiStruct->Gpio_Cs[3], 1); } return _mcspi_open(McspiStruct); }
static int AVL6211_Reset(void) { gpio_out(frontend_reset, 0); msleep(300); gpio_out(frontend_reset, 1); return 0; }
void mcspi_close(Mcspi_t *McspiStruct) { _mcspi_close(McspiStruct); if(McspiStruct->Gpio_Miso) free(McspiStruct->Gpio_Miso); if(McspiStruct->Gpio_Mosi) free(McspiStruct->Gpio_Mosi); if(McspiStruct->Gpio_Sck) free(McspiStruct->Gpio_Sck); if(McspiStruct->Gpio_Cs[0]) { gpio_out(McspiStruct->Gpio_Cs[0], 1); free(McspiStruct->Gpio_Cs[0]); } if(McspiStruct->Gpio_Cs[1]) { gpio_out(McspiStruct->Gpio_Cs[1], 1); free(McspiStruct->Gpio_Cs[1]); } if(McspiStruct->Gpio_Cs[2]) { gpio_out(McspiStruct->Gpio_Cs[2], 1); free(McspiStruct->Gpio_Cs[2]); } if(McspiStruct->Gpio_Cs[3]) { gpio_out(McspiStruct->Gpio_Cs[3], 1); free(McspiStruct->Gpio_Cs[3]); } }
static void led_power_ctrl(int en) { if(en==1){ gpio_out(PAD_TEST_N, 0); } else{ gpio_out(PAD_TEST_N, 1); } }
/* Advance clock(s) */ static void adm_adclk(int clocks) { int i; for (i = 0; i < clocks; i++) { /* Clock high */ gpio_out(eesk, eesk); udelay(EECK_EDGE_TIME); /* Clock low */ gpio_out(eesk, 0); udelay(EECK_EDGE_TIME); } }
// ********************* LOW-LEVEL ISSP SUBROUTINE SECTION ******************** // **************************************************************************** // **** PROCESSOR SPECIFIC **** // **************************************************************************** // **** USER ATTENTION REQUIRED **** // **************************************************************************** // RemoveTargetVDD() // Remove power from the target PSoC's Vdd pin. // **************************************************************************** void RemoveTargetVDD(void) { #if 0 gpio_tlmm_config(LED_26V_EN); gpio_tlmm_config(EXT_TSP_SCL); gpio_tlmm_config(EXT_TSP_SDA); gpio_tlmm_config(EXT_TSP_RST); gpio_out(LED_26V_EN, GPIO_LOW_VALUE); gpio_out(EXT_TSP_SCL, GPIO_LOW_VALUE); gpio_out(EXT_TSP_SDA, GPIO_LOW_VALUE); gpio_out(EXT_TSP_RST, GPIO_LOW_VALUE); #endif gpio_direction_output(_3_GPIO_TOUCH_EN, 0); }
static void handle_outbound(struct aura_node *node, struct aura_object *o, struct aura_buffer *buf) { int ret = -EIO; if (OPCODE("export")) { int gpio = aura_buffer_get_u32(buf); slog(4, SLOG_DEBUG, "gpio: export %d", gpio); ret = gpio_export(gpio); } else if (OPCODE("write")) { int gpio = aura_buffer_get_u32(buf); int value = aura_buffer_get_u32(buf); slog(4, SLOG_DEBUG, "gpio: write gpio %d value %d", gpio, value); ret = gpio_write(gpio, value); } else if (OPCODE("in")) { int gpio = aura_buffer_get_u32(buf); ret = gpio_in(gpio); } else if (OPCODE("out")) { int gpio = aura_buffer_get_u32(buf); ret = gpio_out(gpio); } else if (OPCODE("read")) { int gpio = aura_buffer_get_u32(buf); ret = gpio_read(gpio, &gpio); aura_buffer_rewind(buf); aura_buffer_put_u32(buf, gpio); } slog(0, SLOG_DEBUG, "gpio ret = %d", ret); if (ret) { aura_call_fail(node, o); return; } aura_queue_buffer(&node->inbound_buffers, buf); }
static int smc_hw_deactive(smc_dev_t *smc) { if(smc->active) { unsigned long sc_reg0 = SMC_READ_REG(REG0); SMCCARD_HW_Reg0_t *sc_reg0_reg = (void *)&sc_reg0; sc_reg0_reg->rst_level = 0; sc_reg0_reg->enable= 0; sc_reg0_reg->start_atr = 0; sc_reg0_reg->start_atr_en = 0; sc_reg0_reg->clk_en=0; SMC_WRITE_REG(REG0,sc_reg0); udelay(200); if(smc->reset) { smc->reset(NULL, 1); } else { if(smc->reset_pin != -1) { gpio_request(smc->reset_pin, "smc:RESET"); gpio_out(smc->reset_pin, 1); } } smc->active = 0; } return 0; }
static inline void _power_off_backlight(void) { mutex_lock(&bl_power_mutex); if (!bl_real_status) { mutex_unlock(&bl_power_mutex); return; } #if (BL_CTL==BL_CTL_GPIO) gpio_out(PAD_GPIOD_1, 0); #elif (BL_CTL==BL_CTL_PWM) gpio_out(PAD_GPIOC_8, 0); aml_set_reg32_bits(P_PWM_MISC_REG_CD, 0, 1, 1); //disable pwm_d #endif bl_real_status = 0; mutex_unlock(&bl_power_mutex); }
static int ite9173_fe_resume(struct aml_fe_dev *dev) { printk("ite9173_fe_resume\n"); gpio_out(dev->reset_gpio, 0); msleep(300); gpio_out(dev->reset_gpio, 1); msleep(200); gpio_out(dev->tuner_power_gpio, 1); msleep(200); if(Error_NO_ERROR != Demodulator_initialize (pdemod, streamType)) return -1; return 0; }
static int ite9173_fe_enter_mode(struct aml_fe *fe, int mode) { struct aml_fe_dev *dev = fe->dtv_demod; pr_dbg("=========================demod init\r\n"); gpio_out(dev->reset_gpio, 0); msleep(300); gpio_out(dev->reset_gpio, 1); msleep(200); gpio_out(dev->tuner_power_gpio, 1); msleep(200); if(Error_NO_ERROR != Demodulator_initialize (pdemod, streamType)) return -1; return 0; }
//####################################################################################### void _screen_backlight_off(tDisplay *pDisplay) { switch(pDisplay->LcdType) { case MI0283: gpio_out(pDisplay->BackLight, 0); return; } }
/* Enable outputs with specified value to the chip */ static void adm_enout(__u8 pins, __u8 val) { /* Prepare GPIO output value */ gpio_out(pins, val); /* Enable GPIO outputs */ gpio_outen(pins, pins); udelay(EECK_EDGE_TIME); }
// Refer to H/W schematics static void m3ref_lcd_backlight_power_ctrl(Bool_t status) { printk(KERN_INFO "%s() Power %s\n", __FUNCTION__, (status ? "ON" : "OFF")); if( status == ON ){ aml_set_reg32_bits(P_LED_PWM_REG0, 1, 12, 2); msleep(300); // wait for PWM charge gpio_out(PAD_GPIOD_1, gpio_status_out); gpio_out_high(PAD_GPIOD_1); // set_gpio_val(GPIOD_bank_bit0_9(1), GPIOD_bit_bit0_9(1), 1); // set_gpio_mode(GPIOD_bank_bit0_9(1), GPIOD_bit_bit0_9(1), GPIO_OUTPUT_MODE); } else{ //BL_EN -> GPIOD_1: 0 gpio_out(PAD_GPIOD_1, gpio_status_out); gpio_out_low(PAD_GPIOD_1); // set_gpio_val(GPIOD_bank_bit0_9(1), GPIOD_bit_bit0_9(1), 0); // set_gpio_mode(GPIOD_bank_bit0_9(1), GPIOD_bit_bit0_9(1), GPIO_OUTPUT_MODE); } }
// ********************* LOW-LEVEL ISSP SUBROUTINE SECTION ******************** // **************************************************************************** // **** PROCESSOR SPECIFIC **** // **************************************************************************** // **** USER ATTENTION REQUIRED **** // **************************************************************************** // AssertXRES() // Set XRES pin High // **************************************************************************** void AssertXRES(void) { #if 0 gpio_tlmm_config(EXT_TSP_RST); gpio_out(EXT_TSP_RST, GPIO_HIGH_VALUE); clk_busy_wait(1000); clk_busy_wait(1000); clk_busy_wait(1000); #endif }
// ********************* LOW-LEVEL ISSP SUBROUTINE SECTION ******************** // **************************************************************************** // **** PROCESSOR SPECIFIC **** // **************************************************************************** // **** USER ATTENTION REQUIRED **** // **************************************************************************** // RemoveTargetVDD() // Remove power from the target PSoC's Vdd pin. // **************************************************************************** void RemoveTargetVDD(void) { #if 0 gpio_tlmm_config(LED_26V_EN); gpio_tlmm_config(EXT_TSP_SCL); gpio_tlmm_config(EXT_TSP_SDA); gpio_tlmm_config(EXT_TSP_RST); gpio_out(LED_26V_EN, GPIO_LOW_VALUE); gpio_out(EXT_TSP_SCL, GPIO_LOW_VALUE); gpio_out(EXT_TSP_SDA, GPIO_LOW_VALUE); gpio_out(EXT_TSP_RST, GPIO_LOW_VALUE); #else #if !defined(CONFIG_KOR_MODEL_SHV_E160S) && !defined(CONFIG_KOR_MODEL_SHV_E160K) && !defined (CONFIG_KOR_MODEL_SHV_E160L) printk("[TKEY] %s: tkey_vdd_enable(OFF)\n", __func__); #endif tkey_vdd_enable(0); #endif //gpio_direction_output(_3_GPIO_TOUCH_EN, 0); }
static int aml_ledlogo_suspend(struct early_suspend *handler) { // printk("aml_ledlogo_suspend !!!!!!!!!!!!!###################\n"); if(g_ledlogoEnableFlag) { // printk("do aml_ledlogo_suspend !!!!!!!!!!!!!###################\n"); gpio_out(PAD_GPIOD_3, 0); } return 0 ; }
static void adm_read(int cs, char *buf, unsigned int bits) { int i, len = (bits + 7) / 8; __u8 mask; gpio_out(eecs, (cs ? eecs : 0)); udelay(EECK_EDGE_TIME); /* Byte assemble from MSB to LSB */ for (i = 0; i < len; i++) { __u8 byte; /* Bit bang from MSB to LSB */ for (mask = 0x80, byte = 0; mask && bits > 0; mask >>= 1, bits --) { __u8 gp; /* Clock low */ gpio_out(eesk, 0); udelay(EECK_EDGE_TIME); /* Input on rising edge */ gp = gpio_in(); if (gp & eedi) byte |= mask; /* Clock high */ gpio_out(eesk, eesk); udelay(EECK_EDGE_TIME); } *buf++ = byte; } /* Clock low */ gpio_out(eesk, 0); udelay(EECK_EDGE_TIME); if (cs) gpio_out(eecs, 0); }
void motor_prepare(void) { // motor1 gpio_high(M1_EN); gpio_high(M1_STEP); gpio_high(M1_DIR); gpio_out(M1_EN); gpio_out(M1_STEP); gpio_out(M1_DIR); // motor2 gpio_high(M2_EN); gpio_high(M2_STEP); gpio_high(M2_DIR); gpio_out(M2_EN); gpio_out(M2_STEP); gpio_out(M2_DIR); // timer 1 FastPWM with interrupt TCCR1A = _BV(WGM11); TCCR1B = _BV(WGM12) | _BV(WGM13) | 1; ICR1 = 0x0FFF; // 122Hz TIMSK1 = _BV(TOIE1); }
static void lcd_power_ctrl(Bool_t status) { mutex_lock(&lcd_power_mutex); printk(KERN_INFO "%s() Power %s\n", __FUNCTION__, (status ? "ON" : "OFF")); if (status) { //GPIOA27 -> LCD_PWR_EN#: 0 lcd 3.3v gpio_out(PAD_GPIOA_27, 1); lcd_mdelay(20); //GPIOC2 -> VCCx3_EN: 0 //gpio_out(PAD_GPIOC_2, 1); #ifdef CONFIG_AW_AXP axp_gpio_set_io(3,1); axp_gpio_set_value(3, 0); #endif lcd_mdelay(20); lcd_signals_ports_ctrl(ON); lcd_mdelay(200); data_status = status; } else { data_status = status; lcd_mdelay(30); lcd_signals_ports_ctrl(OFF); lcd_mdelay(20); //GPIOC2 -> VCCx3_EN: 1 //gpio_out(PAD_GPIOC_2, 1); #ifdef CONFIG_AW_AXP axp_gpio_set_io(3,0); #endif lcd_mdelay(20); //gpio_out(PAD_GPIOD_1, 0); //GPIOA27 -> LCD_PWR_EN#: 1 lcd 3.3v gpio_out(PAD_GPIOA_27, 0); lcd_mdelay(100); //power down sequence, needed } printk(KERN_INFO "%s() Power %s finished\n", __FUNCTION__, (status ? "ON" : "OFF")); mutex_unlock(&lcd_power_mutex); }
static void adm_write(int cs, char *buf, unsigned int bits) { int i, len = (bits + 7) / 8; __u8 mask; gpio_out(eecs, (cs ? eecs : 0)); udelay(EECK_EDGE_TIME); /* Byte assemble from MSB to LSB */ for (i = 0; i < len; i++) { /* Bit bang from MSB to LSB */ for (mask = 0x80; mask && bits > 0; mask >>= 1, bits --) { /* Clock low */ gpio_out(eesk, 0); udelay(EECK_EDGE_TIME); /* Output on rising edge */ gpio_out(eedi, ((mask & buf[i]) ? eedi : 0)); udelay(EEDI_SETUP_TIME); /* Clock high */ gpio_out(eesk, eesk); udelay(EECK_EDGE_TIME); } } /* Clock low */ gpio_out(eesk, 0); udelay(EECK_EDGE_TIME); if (cs) gpio_out(eecs, 0); }
static inline void _power_on_backlight(void) { mutex_lock(&bl_power_mutex); if (bl_real_status) { mutex_unlock(&bl_power_mutex); return; } aml_set_reg32_bits(P_LED_PWM_REG0, 1, 12, 2); lcd_mdelay(20); #if (BL_CTL==BL_CTL_GPIO) //BL_EN -> GPIOD_1: 1 gpio_out(PAD_GPIOD_1, 1); #elif (BL_CTL==BL_CTL_PWM) gpio_out(PAD_GPIOC_8, 1); aml_set_reg32_bits(P_PWM_MISC_REG_CD, PWM_PRE_DIV, 16, 7); aml_set_reg32_bits(P_PWM_MISC_REG_CD, 1, 23, 1); aml_set_reg32_bits(P_PWM_MISC_REG_CD, 1, 1, 1); //enable pwm_d aml_write_reg32(P_PERIPHS_PIN_MUX_2, aml_read_reg32(P_PERIPHS_PIN_MUX_2) | (1<<3)); //enable pwm pinmux #endif bl_real_status = 1; mutex_unlock(&bl_power_mutex); }
static long bcm2079x_dev_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { struct bcm2079x_dev *bcm2079x_dev = filp->private_data; switch (cmd) { case BCMNFC_READ_FULL_PACKET: break; case BCMNFC_READ_MULTI_PACKETS: break; case BCMNFC_CHANGE_ADDR: dev_info(&bcm2079x_dev->client->dev, "%s, BCMNFC_CHANGE_ADDR (%x, %lx):\n", __func__, cmd, arg); change_client_addr(bcm2079x_dev, arg); break; case BCMNFC_POWER_CTL: dev_info(&bcm2079x_dev->client->dev, "%s, BCMNFC_POWER_CTL (%x, %lx):\n", __func__, cmd, arg); gpio_out(bcm2079x_dev->en_gpio, arg); break; case BCMNFC_WAKE_CTL: dev_info(&bcm2079x_dev->client->dev, "%s, BCMNFC_WAKE_CTL (%x, %lx):\n", __func__, cmd, arg); gpio_out(bcm2079x_dev->wake_gpio, arg); break; default: dev_err(&bcm2079x_dev->client->dev, "%s, unknown cmd (%x, %lx)\n", __func__, cmd, arg); return 0; } return 0; }
INT32 wmt_plat_rtc_ctrl ( ENUM_PIN_STATE state ) { #if EXT_OSC_EN switch(state) { case PIN_STA_INIT: gpio_out(MTK_RTC_PIN,1); WMT_DBG_FUNC("WMT-PLAT:RTC init \n"); break; default: WMT_WARN_FUNC("WMT-PLAT:Warnning, invalid state(%d) on RTC\n", state); break; } #endif return 0; }
static int smc_hw_active(smc_dev_t *smc) { if(!smc->active) { if(smc->reset) { smc->reset(NULL, 0); } else { if(smc->reset_pin != -1) { gpio_request(smc->reset_pin, "smc:RESET"); gpio_out(smc->reset_pin, 0); } } udelay(200); smc_hw_setup(smc); smc->active = 1; } return 0; }