can: mcp251xfd: only configure PIN1 when rx_int is set
When rx_int is used th mcp251xfd_chip_rx_int_enable and mcp251xfd_chip_rx_int_disable function configure both PIN0 and PIN1. To prepare the support of the GPIOS only configure PIN1 with regmap_update_bits. This way PIN0 can be used as GPIO while PIN1 is used as rx_int interrupt. Signed-off-by: Gregor Herburger <gregor.herburger@ew.tq-group.com> Tested-by: Viken Dadhaniya <viken.dadhaniya@oss.qualcomm.com> Signed-off-by: Viken Dadhaniya <viken.dadhaniya@oss.qualcomm.com> Reviewed-by: Manivannan Sadhasivam <mani@kernel.org> Link: https://patch.msgid.link/20251001091006.4003841-5-viken.dadhaniya@oss.qualcomm.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
committed by
Marc Kleine-Budde
parent
c902835fc6
commit
d35fa005f5
@@ -608,23 +608,21 @@ static int mcp251xfd_set_bittiming(const struct mcp251xfd_priv *priv)
|
||||
|
||||
static int mcp251xfd_chip_rx_int_enable(const struct mcp251xfd_priv *priv)
|
||||
{
|
||||
u32 val;
|
||||
u32 val, mask;
|
||||
|
||||
if (!priv->rx_int)
|
||||
return 0;
|
||||
|
||||
/* Configure GPIOs:
|
||||
* - PIN0: GPIO Input
|
||||
* - PIN1: GPIO Input/RX Interrupt
|
||||
/* Configure PIN1 as RX Interrupt:
|
||||
*
|
||||
* PIN1 must be Input, otherwise there is a glitch on the
|
||||
* rx-INT line. It happens between setting the PIN as output
|
||||
* (in the first byte of the SPI transfer) and configuring the
|
||||
* PIN as interrupt (in the last byte of the SPI transfer).
|
||||
*/
|
||||
val = MCP251XFD_REG_IOCON_PM0 | MCP251XFD_REG_IOCON_TRIS1 |
|
||||
MCP251XFD_REG_IOCON_TRIS0;
|
||||
return regmap_write(priv->map_reg, MCP251XFD_REG_IOCON, val);
|
||||
val = MCP251XFD_REG_IOCON_TRIS(1);
|
||||
mask = MCP251XFD_REG_IOCON_TRIS(1) | MCP251XFD_REG_IOCON_PM(1);
|
||||
return regmap_update_bits(priv->map_reg, MCP251XFD_REG_IOCON, mask, val);
|
||||
}
|
||||
|
||||
static int mcp251xfd_chip_rx_int_disable(const struct mcp251xfd_priv *priv)
|
||||
@@ -634,13 +632,9 @@ static int mcp251xfd_chip_rx_int_disable(const struct mcp251xfd_priv *priv)
|
||||
if (!priv->rx_int)
|
||||
return 0;
|
||||
|
||||
/* Configure GPIOs:
|
||||
* - PIN0: GPIO Input
|
||||
* - PIN1: GPIO Input
|
||||
*/
|
||||
val = MCP251XFD_REG_IOCON_PM1 | MCP251XFD_REG_IOCON_PM0 |
|
||||
MCP251XFD_REG_IOCON_TRIS1 | MCP251XFD_REG_IOCON_TRIS0;
|
||||
return regmap_write(priv->map_reg, MCP251XFD_REG_IOCON, val);
|
||||
/* Configure PIN1 as GPIO Input */
|
||||
val = MCP251XFD_REG_IOCON_PM(1) | MCP251XFD_REG_IOCON_TRIS(1);
|
||||
return regmap_update_bits(priv->map_reg, MCP251XFD_REG_IOCON, val, val);
|
||||
}
|
||||
|
||||
static int mcp251xfd_chip_ecc_init(struct mcp251xfd_priv *priv)
|
||||
|
||||
@@ -335,14 +335,19 @@
|
||||
#define MCP251XFD_REG_IOCON_TXCANOD BIT(28)
|
||||
#define MCP251XFD_REG_IOCON_PM1 BIT(25)
|
||||
#define MCP251XFD_REG_IOCON_PM0 BIT(24)
|
||||
#define MCP251XFD_REG_IOCON_PM(n) (MCP251XFD_REG_IOCON_PM0 << (n))
|
||||
#define MCP251XFD_REG_IOCON_GPIO1 BIT(17)
|
||||
#define MCP251XFD_REG_IOCON_GPIO0 BIT(16)
|
||||
#define MCP251XFD_REG_IOCON_GPIO(n) (MCP251XFD_REG_IOCON_GPIO0 << (n))
|
||||
#define MCP251XFD_REG_IOCON_GPIO_MASK GENMASK(17, 16)
|
||||
#define MCP251XFD_REG_IOCON_LAT1 BIT(9)
|
||||
#define MCP251XFD_REG_IOCON_LAT0 BIT(8)
|
||||
#define MCP251XFD_REG_IOCON_LAT(n) (MCP251XFD_REG_IOCON_LAT0 << (n))
|
||||
#define MCP251XFD_REG_IOCON_LAT_MASK GENMASK(9, 8)
|
||||
#define MCP251XFD_REG_IOCON_XSTBYEN BIT(6)
|
||||
#define MCP251XFD_REG_IOCON_TRIS1 BIT(1)
|
||||
#define MCP251XFD_REG_IOCON_TRIS0 BIT(0)
|
||||
#define MCP251XFD_REG_IOCON_TRIS(n) (MCP251XFD_REG_IOCON_TRIS0 << (n))
|
||||
|
||||
#define MCP251XFD_REG_CRC 0xe08
|
||||
#define MCP251XFD_REG_CRC_FERRIE BIT(25)
|
||||
|
||||
Reference in New Issue
Block a user