Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 208475
b: refs/heads/master
c: 4a22b8a
h: refs/heads/master
i:
  208473: 5bc6d89
  208471: bc6e05a
v: v3
  • Loading branch information
Marc Kleine-Budde authored and Linus Torvalds committed Aug 11, 2010
1 parent 461b43d commit 6752344
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 22e3d63147c9608dc48ac6a6d9973eba8672efbe
refs/heads/master: 4a22b8a4ad5561436b16f5278d2f9e406ffb8705
22 changes: 15 additions & 7 deletions trunk/drivers/gpio/max730x.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static int max7301_direction_input(struct gpio_chip *chip, unsigned offset)
{
struct max7301 *ts = container_of(chip, struct max7301, chip);
u8 *config;
u8 offset_bits;
u8 offset_bits, pin_config;
int ret;

/* First 4 pins are unused in the controller */
Expand All @@ -63,12 +63,15 @@ static int max7301_direction_input(struct gpio_chip *chip, unsigned offset)

config = &ts->port_config[offset >> 2];

if (ts->input_pullup_active & BIT(offset))
pin_config = PIN_CONFIG_IN_PULLUP;
else
pin_config = PIN_CONFIG_IN_WO_PULLUP;

mutex_lock(&ts->lock);

/* Standard GPIO API doesn't support pull-ups, has to be extended.
* Hard-coding no pollup for now. */
*config = (*config & ~(PIN_CONFIG_MASK << offset_bits))
| (PIN_CONFIG_IN_WO_PULLUP << offset_bits);
| (pin_config << offset_bits);

ret = ts->write(ts->dev, 0x08 + (offset >> 2), *config);

Expand Down Expand Up @@ -177,6 +180,7 @@ int __devinit __max730x_probe(struct max7301 *ts)
/* Power up the chip and disable IRQ output */
ts->write(dev, 0x04, 0x01);

ts->input_pullup_active = pdata->input_pullup_active;
ts->chip.label = dev->driver->name;

ts->chip.direction_input = max7301_direction_input;
Expand All @@ -191,13 +195,17 @@ int __devinit __max730x_probe(struct max7301 *ts)
ts->chip.owner = THIS_MODULE;

/*
* tristate all pins in hardware and cache the
* initialize pullups according to platform data and cache the
* register values for later use.
*/
for (i = 1; i < 8; i++) {
int j;
/* 0xAA means input with internal pullup disabled */
ts->write(dev, 0x08 + i, 0xAA);
/*
* initialize port_config with "0xAA", which means
* input with internal pullup disabled. This is needed
* to avoid writing zeros (in the inner for loop),
* which is not allowed according to the datasheet.
*/
ts->port_config[i] = 0xAA;
for (j = 0; j < 4; j++) {
int offset = (i - 1) * 4 + j;
Expand Down
8 changes: 8 additions & 0 deletions trunk/include/linux/spi/max7301.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct max7301 {
struct mutex lock;
u8 port_config[8]; /* field 0 is unused */
u32 out_level; /* cached output levels */
u32 input_pullup_active;
struct gpio_chip chip;
struct device *dev;
int (*write)(struct device *dev, unsigned int reg, unsigned int val);
Expand All @@ -20,6 +21,13 @@ struct max7301 {
struct max7301_platform_data {
/* number assigned to the first GPIO */
unsigned base;
/*
* bitmask controlling the pullup configuration,
*
* _note_ the 4 lowest bits are unused, because the first 4
* ports of the controller are not used, too.
*/
u32 input_pullup_active;
};

extern int __max730x_remove(struct device *dev);
Expand Down

0 comments on commit 6752344

Please sign in to comment.