mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-01 10:45:49 +00:00
gpio: graniterapids: Determine if GPIO pad can be used by driver
Add check of HOSTSW_MODE bit to determine if GPIO pad can be used by the driver. Cc: stable@vger.kernel.org Signed-off-by: Alan Borzeszkowski <alan.borzeszkowski@linux.intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Acked-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20241204070415.1034449-6-mika.westerberg@linux.intel.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
parent
15636b00a0
commit
0588504d28
@ -37,6 +37,7 @@
|
||||
#define GNR_GPI_STATUS_OFFSET 0x14
|
||||
#define GNR_GPI_ENABLE_OFFSET 0x24
|
||||
|
||||
#define GNR_CFG_DW_HOSTSW_MODE BIT(27)
|
||||
#define GNR_CFG_DW_RX_MASK GENMASK(23, 22)
|
||||
#define GNR_CFG_DW_RX_DISABLE FIELD_PREP(GNR_CFG_DW_RX_MASK, 2)
|
||||
#define GNR_CFG_DW_RX_EDGE FIELD_PREP(GNR_CFG_DW_RX_MASK, 1)
|
||||
@ -90,6 +91,20 @@ static int gnr_gpio_configure_line(struct gpio_chip *gc, unsigned int gpio,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gnr_gpio_request(struct gpio_chip *gc, unsigned int gpio)
|
||||
{
|
||||
struct gnr_gpio *priv = gpiochip_get_data(gc);
|
||||
u32 dw;
|
||||
|
||||
dw = readl(gnr_gpio_get_padcfg_addr(priv, gpio));
|
||||
if (!(dw & GNR_CFG_DW_HOSTSW_MODE)) {
|
||||
dev_warn(gc->parent, "GPIO %u is not owned by host", gpio);
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gnr_gpio_get(struct gpio_chip *gc, unsigned int gpio)
|
||||
{
|
||||
const struct gnr_gpio *priv = gpiochip_get_data(gc);
|
||||
@ -141,6 +156,7 @@ static int gnr_gpio_direction_output(struct gpio_chip *gc, unsigned int gpio, in
|
||||
|
||||
static const struct gpio_chip gnr_gpio_chip = {
|
||||
.owner = THIS_MODULE,
|
||||
.request = gnr_gpio_request,
|
||||
.get = gnr_gpio_get,
|
||||
.set = gnr_gpio_set,
|
||||
.get_direction = gnr_gpio_get_direction,
|
||||
|
Loading…
Reference in New Issue
Block a user