Skip to content

Commit

Permalink
gpio/aspeed: Write value on switch to output
Browse files Browse the repository at this point in the history
The Barreleye beep LED turned off during boot despite configuring the
default-state device tree property to "on".

The gpio framework requires the direction_output() callback in struct
gpio_chip to set the value as well as the direction.

Tested by John on Barreleye and Joel on ast2500evb.

Fixes: https://github.com/openbmc/linux/issues/98
Reported-by: John Wang <hsienchiang@gmail.com>
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Signed-off-by: Joel Stanley <joel@jms.id.au>
  • Loading branch information
Andrew Jeffery authored and Joel Stanley committed Aug 8, 2016
1 parent b916113 commit aa65fa6
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions drivers/gpio/gpio-aspeed.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,33 @@ static int aspeed_gpio_get(struct gpio_chip *gc, unsigned int offset)
& GPIO_BIT(offset));
}

static void aspeed_gpio_set(struct gpio_chip *gc, unsigned int offset,
int val)
static void __aspeed_gpio_set(struct gpio_chip *gc, unsigned int offset, int val)
{
u32 reg;
void __iomem *addr;
struct aspeed_gpio *gpio = to_aspeed_gpio(gc);
const struct aspeed_gpio_bank *bank = to_bank(offset);
unsigned long flags;
u32 reg;

spin_lock_irqsave(&gpio->lock, flags);
addr = bank_val_reg(gpio, bank, GPIO_DATA);

reg = ioread32(bank_val_reg(gpio, bank, GPIO_DATA));
reg = ioread32(addr);
if (val)
reg |= GPIO_BIT(offset);
else
reg &= ~GPIO_BIT(offset);

iowrite32(reg, bank_val_reg(gpio, bank, GPIO_DATA));
iowrite32(reg, addr);
}

static void aspeed_gpio_set(struct gpio_chip *gc, unsigned int offset,
int val)
{
struct aspeed_gpio *gpio = to_aspeed_gpio(gc);
unsigned long flags;

spin_lock_irqsave(&gpio->lock, flags);

__aspeed_gpio_set(gc, offset, val);

spin_unlock_irqrestore(&gpio->lock, flags);
}
Expand Down Expand Up @@ -164,6 +174,8 @@ static int aspeed_gpio_dir_out(struct gpio_chip *gc,
reg = ioread32(bank_val_reg(gpio, bank, GPIO_DIR));
iowrite32(reg | GPIO_BIT(offset), bank_val_reg(gpio, bank, GPIO_DIR));

__aspeed_gpio_set(gc, offset, val);

spin_unlock_irqrestore(&gpio->lock, flags);

return 0;
Expand Down

0 comments on commit aa65fa6

Please sign in to comment.