Beispiel #1
0
static int gpio_get_cfg(int gpio)
{
	struct s5p_gpio_bank *bank = gpio_get_bank(gpio);
	int shift = GPIO_BIT(gpio) << 2;

	return (readl(&bank->con) & CON_MASK(GPIO_BIT(gpio))) >> shift;
}
Beispiel #2
0
void stm32_gpio_digital_write(int pin, int value)
{
    if (value)
        GPIO_SetBits(GPIO_PORT(pin), GPIO_BIT(pin));
    else
        GPIO_ResetBits(GPIO_PORT(pin), GPIO_BIT(pin));
}
Beispiel #3
0
void
pxa_gpio_set(int gpio, int on)
{
    if (on)
        GPSR(gpio) = GPIO_BIT(gpio);
    else
        GPCR(gpio) = GPIO_BIT(gpio);
}
Beispiel #4
0
void gpio_cfg_pin(int gpio, int cfg)
{
	unsigned int value;
	struct s5p_gpio_bank *bank = gpio_get_bank(gpio);

	value = readl(&bank->con);
	value &= ~CON_MASK(GPIO_BIT(gpio));
	value |= CON_SFR(GPIO_BIT(gpio), cfg);
	writel(value, &bank->con);
}
void gpio_set_value(int gp, int value)
{
	struct davinci_gpio *bank;

	bank = GPIO_BANK(gp);

	if (value)
		bank->set_data = 1U << GPIO_BIT(gp);
	else
		bank->clr_data = 1U << GPIO_BIT(gp);
}
Beispiel #6
0
int gpio_set_value(unsigned gpio, int value)
{
	struct davinci_gpio *bank;

	bank = GPIO_BANK(gpio);

	if (value)
		bank->set_data = 1U << GPIO_BIT(gpio);
	else
		bank->clr_data = 1U << GPIO_BIT(gpio);

	return 0;
}
Beispiel #7
0
LEVEL CGpio::GetPin(GPIO_GROUP group, int num)
{
	volatile ULONG *pDAT = (volatile ULONG *)GetDat(group);

	if(pDAT == NULL) return ERROR;

//	SetDir(group, num, GPIO_IN);

	if((*pDAT & GPIO_BIT(num)) == GPIO_BIT(num))
		return HIGH;
	else
		return LOW;
}
Beispiel #8
0
int gpio_set_value(unsigned gpio, int value)
{
	unsigned int val;
	struct s5p_gpio_bank *bank = gpio_get_bank(gpio);

	val = readl(&bank->dat);
	val &= ~DAT_MASK(GPIO_BIT(gpio));
	if (value)
		val |= DAT_SET(GPIO_BIT(gpio));
	writel(val, &bank->dat);

	return 0;
}
Beispiel #9
0
int gpio_amlogic_direction_output(struct gpio_chip *chip,unsigned offset, int value)
{
	unsigned int reg,bit;
	if(offset==GPIO_BSD_EN){
		aml_clr_reg32_mask(P_PREG_PAD_GPIO0_O,1<<29);
#ifndef CONFIG_MESON_TRUSTZONE
		aml_set_reg32_mask(P_AO_SECURE_REG0,1<<0);
#else
		meson_secure_reg_write(P_AO_SECURE_REG0, meson_secure_reg_read(P_AO_SECURE_REG0) | (1<<0));
#endif
		if(value)
			aml_set_reg32_mask(P_PREG_PAD_GPIO0_O,1<<31);//out put high
		else
			aml_clr_reg32_mask(P_PREG_PAD_GPIO0_O,1<<31);//out put low
		aml_clr_reg32_mask(P_PREG_PAD_GPIO0_O,1<<30);//out put enable
		return 0;
	}
	if(offset==GPIO_TEST_N){
		if(value)
			aml_set_reg32_mask(P_AO_GPIO_O_EN_N,1<<31);//out put high
		else
			aml_clr_reg32_mask(P_AO_GPIO_O_EN_N,1<<31);//out put low
#ifndef CONFIG_MESON_TRUSTZONE
		aml_set_reg32_mask(P_AO_SECURE_REG0,1);// out put enable
#else
		meson_secure_reg_write(P_AO_SECURE_REG0, meson_secure_reg_read(P_AO_SECURE_REG0) | (1<<0));
#endif
		return 0;
	}
	if(value){
		reg=GPIO_REG(amlogic_pins[offset].out_value_reg_bit);
		bit=GPIO_BIT(amlogic_pins[offset].out_value_reg_bit);
		aml_set_reg32_mask(p_gpio_output_addr[reg],1<<bit);
		gpio_print("out reg=%x,value=%x\n",p_gpio_output_addr[reg],aml_read_reg32(p_gpio_output_addr[reg]));
	}
	else{
		reg=GPIO_REG(amlogic_pins[offset].out_value_reg_bit);
		bit=GPIO_BIT(amlogic_pins[offset].out_value_reg_bit);
		aml_clr_reg32_mask(p_gpio_output_addr[reg],1<<bit);
		gpio_print("out reg=%x,value=%x\n",p_gpio_output_addr[reg],aml_read_reg32(p_gpio_output_addr[reg]));
	}
	reg=GPIO_REG(amlogic_pins[offset].out_en_reg_bit);
	bit=GPIO_BIT(amlogic_pins[offset].out_en_reg_bit);
	aml_clr_reg32_mask(p_gpio_oen_addr[reg],1<<bit);
	gpio_print("==%s==%d\n",__FUNCTION__,__LINE__);
	gpio_print("oen reg=%x,value=%x\n",p_gpio_oen_addr[reg],aml_read_reg32(p_gpio_oen_addr[reg]));
	gpio_print("value=%d\n",value);
	return 0;
}
Beispiel #10
0
int gpio_direction_output(unsigned gpio, int value)
{
	unsigned int val;
	struct s5p_gpio_bank *bank = gpio_get_bank(gpio);

	gpio_cfg_pin(gpio, EXYNOS_GPIO_OUTPUT);

	val = readl(&bank->dat);
	val &= ~DAT_MASK(GPIO_BIT(gpio));
	if (value)
		val |= DAT_SET(GPIO_BIT(gpio));
	writel(val, &bank->dat);

	return 0;
}
Beispiel #11
0
int stm32_gpio_set_pin_mode(int pin, gpio_pin_mode_t mode)
{
    GPIO_InitTypeDef GPIO_InitStructure;

    STM32_GPIO_PERIPH_ENABLE(GPIO_PERIPH(pin));

    GPIO_InitStructure.GPIO_Pin = GPIO_BIT(pin); 
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

    /* XXX: not all pins are actually available */
    switch (mode)
    {
    case GPIO_PM_INPUT:
        STM32_GPIO_PIN_TYPE_IN(GPIO_InitStructure);
        GPIO_Init(GPIO_PORT(pin), &GPIO_InitStructure);
        break;
    case GPIO_PM_OUTPUT:
        STM32_GPIO_PIN_TYPE_OUT(GPIO_InitStructure);
        GPIO_Init(GPIO_PORT(pin), &GPIO_InitStructure);
        break;
    case GPIO_PM_INPUT_PULLUP:
        STM32_GPIO_PIN_TYPE_IN_PU(GPIO_InitStructure);
        GPIO_Init(GPIO_PORT(pin), &GPIO_InitStructure);
        break;
    case GPIO_PM_INPUT_PULLDOWN:
        STM32_GPIO_PIN_TYPE_IN_PD(GPIO_InitStructure);
        GPIO_Init(GPIO_PORT(pin), &GPIO_InitStructure);
        break;
    default:
        tp_err("Pinmode %d is not supported yet\n", mode);
        return -1;
    }
    return 0;
}
Beispiel #12
0
void __gpio_set(int gpio, u32 value)
{
	int port = GPIO_PORT(gpio);
	int bit = GPIO_BIT(gpio);

	writel(value, __GPIO_BASE(port) + (0x4 << bit));
}
Beispiel #13
0
Datei: gpio.c Projekt: E-LLP/n900
int pnx4008_gpio_unregister_pin(unsigned short pin)
{
	unsigned long bit = GPIO_BIT(pin);
	int ret = -EFAULT;	/* Not registered */

	gpio_lock();

	if (GPIO_ISBID(pin)) {
		if (~access_map[GPIO_INDEX] & bit)
			goto out;
		access_map[GPIO_INDEX] &= ~bit;
	} else if (GPIO_ISRAM(pin)) {
		if (~access_map[GPIO_INDEX] & bit)
			goto out;
		access_map[GPIO_INDEX] &= ~bit;
	} else if (GPIO_ISMUX(pin)) {
		if (~access_map[MUX_INDEX] & bit)
			goto out;
		access_map[MUX_INDEX] &= ~bit;
	} else if (GPIO_ISOUT(pin)) {
		if (~access_map[OUTP_INDEX] & bit)
			goto out;
		access_map[OUTP_INDEX] &= ~bit;
	} else if (GPIO_ISIN(pin)) {
		if (~access_map[INP_INDEX] & bit)
			goto out;
		access_map[INP_INDEX] &= ~bit;
	} else
		goto out;
	ret = 0;

out:
	gpio_unlock();
	return ret;
}
Beispiel #14
0
/* The following functions don't check the gpio value, for speed */
u32 __gpio_get(int gpio)
{
	int port = GPIO_PORT(gpio);
	int bit = GPIO_BIT(gpio);

	return readl(__GPIO_DAT(port)) & (1 << bit);
}
Beispiel #15
0
static int __init gumstix_init(void)
{
	printk("gumstix_init: Initialising board...\n"); 
	pxa_map_io();
	pxa_generic_init(); 

	/* Set up nPWE */
	pxa_gpio_mode(GPIO49_nPWE_MD);

	/* Set up the chip selects */ 
	pxa_gpio_mode(GPIO15_nCS_1_MD);

	(void) platform_add_devices(devices, ARRAY_SIZE(devices));
	
	pxa_gpio_func(36, GPIO_MODE, GPIO_IN);
	/* Set rising edge detect for GPIO 36 */ 
	GFER(36) &= ~GPIO_BIT(36); 
	GRER(36) |= (GPIO_BIT(36)); 

	/* We assume that the bootloader has set up the rest for us */ 

	//        set_irq_type(IBOX_ETH_IRQ, IRQT_RISING);
	

	return 0;
}
Beispiel #16
0
int gpio_amlogic_get(struct gpio_chip *chip,unsigned offset)
{
	unsigned int reg,bit;
	gpio_print("==%s==%d\n",__FUNCTION__,__LINE__);
	reg=GPIO_REG(amlogic_pins[offset].input_value_reg_bit);
	bit=GPIO_BIT(amlogic_pins[offset].input_value_reg_bit);
	return aml_get_reg32_bits(p_gpio_input_addr[reg],bit,1);
}
int gpio_direction_input(int gp)
{
	struct davinci_gpio *bank;

	bank = GPIO_BANK(gp);
	setbits_le32(&bank->dir, 1U << GPIO_BIT(gp));
	return 0;
}
Beispiel #18
0
int gpio_get_value(unsigned gpio)
{
	unsigned int value;
	struct s5p_gpio_bank *bank = gpio_get_bank(gpio);

	value = readl(&bank->dat);
	return !!(value & DAT_MASK(GPIO_BIT(gpio)));
}
Beispiel #19
0
int gpio_amlogic_direction_input(struct gpio_chip *chip,unsigned offset)
{
	unsigned int reg,bit;
	gpio_print("==%s==%d\n",__FUNCTION__,__LINE__);
	reg=GPIO_REG(amlogic_pins[offset].out_en_reg_bit);
	bit=GPIO_BIT(amlogic_pins[offset].out_en_reg_bit);
	aml_set_reg32_mask(p_gpio_oen_addr[reg],1<<bit);
	return 0;
}
int gpio_get_value(int gp)
{
	struct davinci_gpio *bank;
	unsigned int ip;

	bank = GPIO_BANK(gp);
	ip = in_le32(&bank->in_data) & (1U << GPIO_BIT(gp));
	return ip ? 1 : 0;
}
int gpio_direction_output(int gp, int value)
{
	struct davinci_gpio *bank;

	bank = GPIO_BANK(gp);
	clrbits_le32(&bank->dir, 1U << GPIO_BIT(gp));
	gpio_set_value(gp, value);
	return 0;
}
Beispiel #22
0
static inline uint32_t
gpio_read(struct tegra_gpio_softc *sc, bus_size_t reg, struct gpio_pin *pin)
{
	int bit;
	uint32_t val;

	bit = GPIO_BIT(pin->gp_pin);
	val = bus_read_4(sc->mem_res, reg + GPIO_REGNUM(pin->gp_pin));
	return (val >> bit) & 1;
}
Beispiel #23
0
void gpio_set_rate(int gpio, int mode)
{
	unsigned int value;
	struct s5p_gpio_bank *bank = gpio_get_bank(gpio);

	value = readl(&bank->drv);
	value &= ~RATE_MASK(GPIO_BIT(gpio));

	switch (mode) {
	case EXYNOS_GPIO_DRV_FAST:
	case EXYNOS_GPIO_DRV_SLOW:
		value |= RATE_SET(GPIO_BIT(gpio));
		break;
	default:
		return;
	}

	writel(value, &bank->drv);
}
Beispiel #24
0
void gpio_set_pull(int gpio, int mode)
{
	unsigned int value;
	struct s5p_gpio_bank *bank = gpio_get_bank(gpio);

	value = readl(&bank->pull);
	value &= ~PULL_MASK(GPIO_BIT(gpio));

	switch (mode) {
	case EXYNOS_GPIO_PULL_DOWN:
	case EXYNOS_GPIO_PULL_UP:
		value |= PULL_MODE(GPIO_BIT(gpio), mode);
		break;
	default:
		break;
	}

	writel(value, &bank->pull);
}
Beispiel #25
0
void CGpio::SetPin(GPIO_GROUP group, int num, LEVEL level)
{
	volatile ULONG *pDAT = (volatile ULONG *)GetDat(group);

	if(pDAT == NULL) return;

//	SetDir(group, num, GPIO_OUT);

	(level) ? (*pDAT |= GPIO_BIT(num)) : (*pDAT &= ~GPIO_BIT(num));
}
Beispiel #26
0
static inline void ti_arm_mcu_pin_mode_i2c(int pin, int scl, int i2c_af)
{
    ti_arm_mcu_periph_enable(ti_arm_mcu_gpio_periph(pin));
    if (i2c_af)
        MAP_GPIOPinConfigure(i2c_af);
    MAP_GPIOPinTypeI2C(ti_arm_mcu_gpio_base(pin), GPIO_BIT(pin));
    if (scl)
        ti_arm_mcu_pin_config(pin, GPIO_PIN_TYPE_STD_WPU);
    else
        ti_arm_mcu_pin_config(pin, GPIO_PIN_TYPE_OD);
}
Beispiel #27
0
void	gpio_amlogic_set(struct gpio_chip *chip,unsigned offset, int value)
{
	unsigned int reg,bit;
	reg=GPIO_REG(amlogic_pins[offset].out_value_reg_bit);
	bit=GPIO_BIT(amlogic_pins[offset].out_value_reg_bit);
	gpio_print("==%s==%d\n",__FUNCTION__,__LINE__);
	if(value)
		aml_set_reg32_mask(p_gpio_output_addr[reg],1<<bit);
	else
		aml_clr_reg32_mask(p_gpio_output_addr[reg],1<<bit);
}
Beispiel #28
0
/*
 * Routine: gpio_config_uart
 * Description: Force GPIO_PI3 low on Seaboard so UART4 works.
 */
void gpio_config_uart(void)
{
	int gp = GPIO_PI3;
	struct gpio_ctlr *gpio = (struct gpio_ctlr *)NV_PA_GPIO_BASE;
	struct gpio_ctlr_bank *bank = &gpio->gpio_bank[GPIO_BANK(gp)];
	u32 val;

	/* Enable UART via GPIO_PI3 (port 8, bit 3) so serial console works */
	val = readl(&bank->gpio_config[GPIO_PORT(gp)]);
	val |= 1 << GPIO_BIT(gp);
	writel(val, &bank->gpio_config[GPIO_PORT(gp)]);

	val = readl(&bank->gpio_out[GPIO_PORT(gp)]);
	val &= ~(1 << GPIO_BIT(gp));
	writel(val, &bank->gpio_out[GPIO_PORT(gp)]);

	val = readl(&bank->gpio_dir_out[GPIO_PORT(gp)]);
	val |= 1 << GPIO_BIT(gp);
	writel(val, &bank->gpio_dir_out[GPIO_PORT(gp)]);
}
Beispiel #29
0
/* --------------------------------------------------------------------------
 *
 * Interrupts
 *
 */
static inline void
intr_write_masked(struct tegra_gpio_softc *sc, bus_addr_t reg,
    struct tegra_gpio_irqsrc *tgi, uint32_t val)
{
	uint32_t tmp;
	int bit;

	bit = GPIO_BIT(tgi->irq);
	tmp = 0x100 << bit;		/* mask */
	tmp |= (val & 1) << bit;	/* value */
	bus_write_4(sc->mem_res, reg + GPIO_REGNUM(tgi->irq), tmp);
}
Beispiel #30
0
void gpio_set_drv(int gpio, int mode)
{
	unsigned int value;
	struct s5p_gpio_bank *bank = gpio_get_bank(gpio);

	value = readl(&bank->drv);
	value &= ~DRV_MASK(GPIO_BIT(gpio));

	switch (mode) {
	case EXYNOS_GPIO_DRV_1X:
	case EXYNOS_GPIO_DRV_2X:
	case EXYNOS_GPIO_DRV_3X:
	case EXYNOS_GPIO_DRV_4X:
		value |= DRV_SET(GPIO_BIT(gpio), mode);
		break;
	default:
		return;
	}

	writel(value, &bank->drv);
}