net: can: Use syscon regmap for TI specific RAMINIT register
Subsystems (4)
v3 cover net: can: Use syscon regmap for TI specific RAMINIT register
Hi,
Some hardware (TI am43xx) has a buggy RAMINIT DONE mechanism and it might not always set the DONE bit. This will result in a lockup in c_can_hw_raminit_wait_ti(), so patch 1 adds a timeout mechanism there.
There is a non compliancy within TI platforms with respect to the layout of the RAMINIT register. The patches 2 and 3 address this issue and make a flexible but standard way of defining the RAMINIT hardware register layout in the device tree. The RAMINIT register is accessed using the syscon regmap framework.
Patches available at
[email protected]:rogerq/linux.git [for-v3.19/can]
Patches are tested on am335x-evm, am437x-gp-evm and dra7-evm. Board support files to allow CAN testing on these boards are available at
[email protected]:rogerq/linux.git [for-v3.19/omap-dts-dcan]
Changelog:
v3:
- allow driver data to be more than just CAN_ID
- RAMINIT register data moved to driver data instead of device tree file.
v2:
- added "ti" vendor prefix to TI specific raminit properties.
- split DTS changes into a separate series
cheers,
-roger
---
Roger Quadros (8):
net: can: c_can: Add timeout to c_can_hw_raminit_ti()
net: can: c_can: Introduce c_can_driver_data structure
net: can: c_can: Add RAMINIT register information to driver data
net: can: c_can: Add syscon/regmap RAMINIT mechanism
net: can: c_can: Add support for START pulse in RAMINIT sequence
net: can: c_can: Disable pins when CAN interface is down
net: can: c_can: Add support for TI DRA7 DCAN
net: can: c_can: Add support for TI am3352 DCAN
.../devicetree/bindings/net/can/c_can.txt | 5 + drivers/net/can/c_can/c_can.c | 20 ++ drivers/net/can/c_can/c_can.h | 20 +- drivers/net/can/c_can/c_can_platform.c | 207 +++++++++++++++------ 4 files changed, 191 insertions(+), 61 deletions(-)
Signature · 1 line
1.8.3.2
PATCH v3 1/8 net: can: c_can: Add timeout to c_can_hw_raminit_ti()
TI's RAMINIT DONE mechanism is buggy on AM43xx SoC and may not always be set after the START bit is set. Although it seems to work fine even in that case. So add a timeout mechanism to c_can_hw_raminit_wait_ti(). Don't bail out in that failure case but just print an error message.
--- drivers/net/can/c_can/c_can_platform.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/can/c_can/c_can_platform.c +9 -1
@@ -75,10 +75,18 @@ static void c_can_plat_write_reg_aligned_to_32bit(const struct c_can_priv *priv,static void c_can_hw_raminit_wait_ti (const struct c_can_priv *priv,u32 mask,u32 val) { +int timeout =0 ;/* We look only at the bits of our instance. */ val &= mask; -while ((readl (priv->raminit_ctrlreg) & mask) != val) +while ((readl (priv->raminit_ctrlreg) & mask) != val) {udelay (1 ); + timeout++; + +if (timeout ==1000 ) { +dev_err (&priv->dev->dev,"%s: time out\n" , __func__); +break ; + } + } }static void c_can_hw_raminit_ti (const struct c_can_priv *priv,bool enable)
Signature · 1 line
1.8.3.2
PATCH v3 2/8 net: can: c_can: Introduce c_can_driver_data structure
In reply to Roger QuadrosWe want to have more data than just can_dev_id to be present in the driver data e.g. TI platforms need RAMINIT register description. Introduce the c_can_driver_data structure and move the can_dev_id into it.
Tidy up the way it is used on probe().
--- drivers/net/can/c_can/c_can.h | 4 +++ drivers/net/can/c_can/c_can_platform.c | 52 +++++++++++++++++++--------------- 2 files changed, 33 insertions(+), 23 deletions(-)
drivers/net/can/c_can/c_can.h +4 -0
@@ -169,6 +169,10 @@ enum c_can_dev_id { BOSCH_D_CAN, }; +struct c_can_driver_data { +enum c_can_dev_id id; +}; +/* c_can private data structure */ struct c_can_priv {struct can_priv can;/* must be the first member */
drivers/net/can/c_can/c_can_platform.c +29 -23
90 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH v3 3/8 net: can: c_can: Add RAMINIT register information to driver data
In reply to Roger QuadrosSome platforms (e.g. TI) need special RAMINIT register handling. Provide a way to store RAMINIT register description in driver data.
--- drivers/net/can/c_can/c_can.h | 6 ++++++ drivers/net/can/c_can/c_can_platform.c | 2 ++ 2 files changed, 8 insertions(+)
drivers/net/can/c_can/c_can.h +6 -0
@@ -171,6 +171,11 @@ enum c_can_dev_id {struct c_can_driver_data {enum c_can_dev_id id; + +/* RAMINIT register description. Optional. */ +u8 raminit_start_bit;/* START bit position in RAMINIT reg. */ +u8 raminit_done_bit;/* DONE bit position in RAMINIT reg. */ +bool raminit_pulse;/* If set, sets and clears START bit (pulse) */ };/* c_can private data structure */
@@ -196,6 +201,7 @@ struct c_can_priv {u32 comm_rcv_high;u32 rxmasked;u32 dlc[C_CAN_MSG_OBJ_TX_NUM ]; +const struct c_can_driver_data *drvdata; };struct net_device *alloc_c_can_dev (void );
drivers/net/can/c_can/c_can_platform.c +2 -0
@@ -250,6 +250,8 @@ static int c_can_plat_probe(struct platform_device *pdev) } priv =netdev_priv (dev); + priv->drvdata = drvdata; +switch (drvdata->id) {case BOSCH_C_CAN : priv->regs = reg_map_c_can;
Signature · 1 line
1.8.3.2
PATCH v3 4/8 net: can: c_can: Add syscon/regmap RAMINIT mechanism
In reply to Roger QuadrosSome TI SoCs like DRA7 have a RAMINIT register specification different from the other AMxx SoCs and as expected by the existing driver.
To add more insanity, this register is shared with other IPs like DSS, PCIe and PWM.
Provides a more generic mechanism to specify the RAMINIT register location and START/DONE bit position and use the syscon/regmap framework to access the register.
--- .../devicetree/bindings/net/can/c_can.txt | 3 + drivers/net/can/c_can/c_can.h | 9 ++- drivers/net/can/c_can/c_can_platform.c | 93 +++++++++++++--------- 3 files changed, 65 insertions(+), 40 deletions(-)
Documentation/devicetree/bindings/net/can/c_can.txt +3 -0
@@ -12,6 +12,9 @@ Required properties: Optional properties: - ti,hwmods : Must be "d_can<n>" or "c_can<n>", n being the instance number +- syscon-raminit : Handle to system control region that contains the + RAMINIT register and register offset to the RAMINIT + register. Note: "ti,hwmods" field is used to fetch the base address and irq resources from TI, omap hwmod data base during device registration.
drivers/net/can/c_can/c_can.h +7 -2
@@ -178,6 +178,12 @@ struct c_can_driver_data {bool raminit_pulse;/* If set, sets and clears START bit (pulse) */ }; +/* Out of band RAMINIT register access via syscon regmap */ +struct c_can_raminit { +struct regmap *syscon;/* for raminit ctrl. reg. access */ +unsigned int reg;/* register index within syscon */ +}; +/* c_can private data structure */ struct c_can_priv {struct can_priv can;/* must be the first member */
@@ -195,8 +201,7 @@ struct c_can_priv {const u16 *regs;void *priv;/* for board-specific data */ enum c_can_dev_id type; -u32 __iomem *raminit_ctrlreg; -int instance; +struct c_can_raminit raminit_sys;/* RAMINIT via syscon regmap */ void (*raminit) (const struct c_can_priv *priv,bool enable);u32 comm_rcv_high;u32 rxmasked;
drivers/net/can/c_can/c_can_platform.c +55 -38
153 lines not on this page · raw message
Signature · 1 line
1.8.3.2
Re: [PATCH v3 4/8] net: can: c_can: Add syscon/regmap RAMINIT mechanism
Quoted 130 lines · Roger Quadros
Some TI SoCs like DRA7 have a RAMINIT register specification different from the other AMxx SoCs and as expected by the existing driver.
To add more insanity, this register is shared with other IPs like DSS, PCIe and PWM.
Provides a more generic mechanism to specify the RAMINIT register location and START/DONE bit position and use the syscon/regmap framework to access the register.
Signed-off-by Roger Quadros <[email protected]>--- .../devicetree/bindings/net/can/c_can.txt | 3 + drivers/net/can/c_can/c_can.h | 9 ++- drivers/net/can/c_can/c_can_platform.c | 93 +++++++++++++--------- 3 files changed, 65 insertions(+), 40 deletions(-)Documentation/devicetree/bindings/net/can/c_can.txt +3
-0@@ -12,6 +12,9 @@ Required properties: Optional properties: - ti,hwmods : Must be "d_can<n>" or "c_can<n>", n being the instance number +- syscon-raminit : Handle to system control region that contains the + RAMINIT register and register offset to the RAMINIT + register. Note: "ti,hwmods" field is used to fetch the base address and irq resources from TI, omap hwmod data base during device registration.drivers/net/can/c_can/c_can.h +7
-2@@ -178,6 +178,12 @@ struct c_can_driver_data {bool raminit_pulse;/* If set, sets and clears START bit (pulse) */ }; +/* Out of band RAMINIT register access via syscon regmap */ +struct c_can_raminit { +struct regmap *syscon;/* for raminit ctrl. reg. access */ +unsigned int reg;/* register index within syscon */ +}; +/* c_can private data structure */ struct c_can_priv {struct can_priv can;/* must be the first member */ @@ -195,8 +201,7 @@ struct c_can_priv {const u16 *regs;void *priv;/* for board-specific data */ enum c_can_dev_id type; -u32 __iomem *raminit_ctrlreg; -int instance; +struct c_can_raminit raminit_sys;/* RAMINIT via syscon regmap */ void (*raminit) (const struct c_can_priv *priv,bool enable);u32 comm_rcv_high;u32 rxmasked;drivers/net/can/c_can/c_can_platform.c +20
-10@@ -32,14 +32,13 @@#include <linux/clk.h> #include <linux/of.h> #include <linux/of_device.h> +#include <linux/mfd/syscon.h> +#include <linux/regmap.h> #include <linux/can/dev.h> #include "c_can.h" -#define CAN_RAMINIT_START_MASK (i) (0x001 << (i)) -#define CAN_RAMINIT_DONE_MASK (i) (0x100 << (i)) -#define CAN_RAMINIT_ALL_MASK (i) (0x101 << (i))#define DCAN_RAM_INIT_BIT (1 << 3)static DEFINE_SPINLOCK (raminit_lock);/* @@ -72,47 +71,61 @@ static void c_can_plat_write_reg_aligned_to_32bit(const struct c_can_priv *priv,writew (val, priv->base +2 * priv->regs[index]); } -static void c_can_hw_raminit_wait_ti (const struct c_can_priv *priv,u32 mask, -u32 val) +static void c_can_hw_raminit_wait_syscon (const struct c_can_priv *priv, +u32 mask,u32 val) {int timeout =0 ; +const struct c_can_raminit *raminit = &priv->raminit_sys; +u32 ctrl; +/* We look only at the bits of our instance. */ val &= mask; -while ((readl (priv->raminit_ctrlreg) & mask) != val) { +do {udelay (1 ); timeout++; +regmap_read (raminit->syscon, raminit->reg, &ctrl);if (timeout ==1000 ) {dev_err (&priv->dev->dev,"%s: time out\n" , __func__);break ; } - } + }while ((ctrl & mask) != val); } -static void c_can_hw_raminit_ti (const struct c_can_priv *priv,bool enable) +static void c_can_hw_raminit_syscon (const struct c_can_priv *priv,bool enable) { -u32 mask =CAN_RAMINIT_ALL_MASK (priv->instance); +u32 mask;u32 ctrl; +const struct c_can_raminit *raminit = &priv->raminit_sys; +u8 start_bit, done_bit; + + start_bit = priv->drvdata->raminit_start_bit; + done_bit = priv->drvdata->raminit_done_bit;spin_lock (&raminit_lock); - ctrl =readl (priv->raminit_ctrlreg); + mask =1 << start_bit |1 << done_bit; +regmap_read (raminit->syscon, raminit->reg, &ctrl); +/* We clear the done and start bit first. The start bit is * looking at the 0 -> transition, but is not self clearing; * And we clear the init done bit as well.
drivers/net/can/c_can/c_can_platform.c static void c_can_plat_write_reg_aligned_to_32bit(const struct c_can_priv *priv, · line 117
Quoted 10 lines
drivers/net/can/c_can/c_can_platform.c +4
-5+* NOTE: DONE must be written with 1 to clear it. */ - ctrl &= ~CAN_RAMINIT_START_MASK (priv->instance); - ctrl |=CAN_RAMINIT_DONE_MASK (priv->instance); -writel (ctrl, priv->raminit_ctrlreg); - ctrl &= ~CAN_RAMINIT_DONE_MASK (priv->instance); -c_can_hw_raminit_wait_ti (priv, mask, ctrl); + ctrl &= ~(1 << start_bit); + ctrl |=1 << done_bit; +regmap_write (raminit->syscon, raminit->reg, ctrl);
Thanks to Tomi for pointing out.
I need to use regmap_update_bits() instead of regmap_write() for atomic modification, as this register needs to be shared between multiple drivers in case of DRA7 SoC.
cheers,
-roger
Quoted 81 lines
drivers/net/can/c_can/c_can_platform.c +31
-23+ + ctrl &= ~(1 << done_bit); +c_can_hw_raminit_wait_syscon (priv, mask, ctrl);if (enable) {/* Set start bit and wait for the done bit. */ - ctrl |=CAN_RAMINIT_START_MASK (priv->instance); -writel (ctrl, priv->raminit_ctrlreg); - ctrl |=CAN_RAMINIT_DONE_MASK (priv->instance); -c_can_hw_raminit_wait_ti (priv, mask, ctrl); + ctrl |=1 << start_bit; +regmap_write (raminit->syscon, raminit->reg, ctrl); + + ctrl |=1 << done_bit; +c_can_hw_raminit_wait_syscon (priv, mask, ctrl); }spin_unlock (&raminit_lock); }@@ -206,10 +219,11 @@ static int c_can_plat_probe(struct platform_device *pdev)struct net_device *dev;struct c_can_priv *priv;const struct of_device_id *match; -struct resource *mem, *res; +struct resource *mem;int irq;struct clk *clk;const struct c_can_driver_data *drvdata; +struct device_node *np = pdev->dev.of_node; match =of_match_device (c_can_of_table, &pdev->dev);if (match) {@@ -279,27 +293,30 @@ static int c_can_plat_probe(struct platform_device *pdev) priv->read_reg32 = d_can_plat_read_reg32; priv->write_reg32 = d_can_plat_write_reg32; -if (pdev->dev.of_node) - priv->instance =of_alias_get_id (pdev->dev.of_node,"d_can" ); -else - priv->instance = pdev->id; - - res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); -/* Not all D_CAN modules have a separate register for the D_CAN -* RAM initialization. Use default RAM init bit in D_CAN module -* if not specified in DT. +/* Check if we need custom RAMINIT via syscon. Mostly for TI +* platforms. Only supported with DT boot. */ -if (!res) { +if (np &&of_property_read_bool (np,"syscon-raminit" )) { + ret = -EINVAL ; + priv->raminit_sys.syscon =syscon_regmap_lookup_by_phandle (np, +"syscon-raminit" ); +if (IS_ERR (priv->raminit_sys.syscon)) { +dev_err (&pdev->dev, +"couldn't get syscon regmap for RAMINIT reg.\n" ); + goto exit_free_device; + } + +if (of_property_read_u32_index (np,"syscon-raminit" ,1 , + &priv->raminit_sys.reg)) { +dev_err (&pdev->dev, +"couldn't get the RAMINIT reg. offset!\n" ); + goto exit_free_device; + } + + priv->raminit = c_can_hw_raminit_syscon; + }else { priv->raminit = c_can_hw_raminit; -break ; } - - priv->raminit_ctrlreg =devm_ioremap (&pdev->dev, res->start, -resource_size (res)); -if (!priv->raminit_ctrlreg || priv->instance <0 ) -dev_info (&pdev->dev,"control memory is not used for raminit\n" ); -else - priv->raminit = c_can_hw_raminit_ti;break ;default : ret = -EINVAL ;
PATCH v3 5/8 net: can: c_can: Add support for START pulse in RAMINIT sequence
In reply to Roger QuadrosSome SoCs e.g. (TI DRA7xx) need a START pulse to start the RAMINIT sequence i.e. START bit must be set and cleared before checking for the DONE bit status.
--- drivers/net/can/c_can/c_can_platform.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/can/c_can/c_can_platform.c +6 -0
@@ -124,6 +124,12 @@ static void c_can_hw_raminit_syscon(const struct c_can_priv *priv, bool enable) ctrl |=1 << start_bit;regmap_write (raminit->syscon, raminit->reg, ctrl); +/* clear START bit if start pulse is needed */ +if (priv->drvdata->raminit_pulse) { + ctrl &= ~(1 << start_bit); +regmap_write (raminit->syscon, raminit->reg, ctrl); + } + ctrl |=1 << done_bit;c_can_hw_raminit_wait_syscon (priv, mask, ctrl); }
Signature · 1 line
1.8.3.2
PATCH v3 6/8 net: can: c_can: Disable pins when CAN interface is down
In reply to Roger QuadrosDRA7 CAN IP suffers from a problem which causes it to be prevented from fully turning OFF (i.e. stuck in transition) if the module was disabled while there was traffic on the CAN_RX line.
To work around this issue we select the SLEEP pin state by default on probe and use the DEFAULT pin state on CAN up and back to the SLEEP pin state on CAN down.
--- drivers/net/can/c_can/c_can.c | 20 ++++++++++++++++++++ drivers/net/can/c_can/c_can.h | 1 + drivers/net/can/c_can/c_can_platform.c | 20 ++++++++++++++++++++ 3 files changed, 41 insertions(+)
drivers/net/can/c_can/c_can.c +20 -0
@@ -35,6 +35,7 @@#include <linux/list.h> #include <linux/io.h> #include <linux/pm_runtime.h> +#include <linux/pinctrl/consumer.h> #include <linux/can.h> #include <linux/can/dev.h>
@@ -603,6 +604,15 @@ static int c_can_start(struct net_device *dev) priv->can.state =CAN_STATE_ERROR_ACTIVE ; +/* activate pins */ +if (!IS_ERR (priv->pinctrl)) { +struct pinctrl_state *s; + + s =pinctrl_lookup_state (priv->pinctrl,PINCTRL_STATE_DEFAULT ); +if (!IS_ERR (s)) +pinctrl_select_state (priv->pinctrl, s); + } +return 0 ; }
@@ -611,6 +621,16 @@ static void c_can_stop(struct net_device *dev)struct c_can_priv *priv =netdev_priv (dev);c_can_irq_control (priv, false); + +/* deactivate pins */ +if (!IS_ERR (priv->pinctrl)) { +struct pinctrl_state *s; + + s =pinctrl_lookup_state (priv->pinctrl,PINCTRL_STATE_SLEEP ); +if (!IS_ERR (s)) +pinctrl_select_state (priv->pinctrl, s); + } + priv->can.state =CAN_STATE_STOPPED ; }
drivers/net/can/c_can/c_can.h +1 -0
@@ -207,6 +207,7 @@ struct c_can_priv {u32 rxmasked;u32 dlc[C_CAN_MSG_OBJ_TX_NUM ];const struct c_can_driver_data *drvdata; +struct pinctrl *pinctrl; };struct net_device *alloc_c_can_dev (void );
drivers/net/can/c_can/c_can_platform.c +20 -0
@@ -34,6 +34,7 @@#include <linux/of_device.h> #include <linux/mfd/syscon.h> #include <linux/regmap.h> +#include <linux/pinctrl/consumer.h> #include <linux/can/dev.h>
@@ -230,6 +231,7 @@ static int c_can_plat_probe(struct platform_device *pdev)struct clk *clk;const struct c_can_driver_data *drvdata;struct device_node *np = pdev->dev.of_node; +struct pinctrl *pinctrl; match =of_match_device (c_can_of_table, &pdev->dev);if (match) {
@@ -241,6 +243,23 @@ static int c_can_plat_probe(struct platform_device *pdev)return -ENODEV ; } + pinctrl =devm_pinctrl_get (&pdev->dev); +if (!IS_ERR (pinctrl)) { +struct pinctrl_state *s; + +/* Deactivate pins to prevent DRA7 DCAN IP from being +* stuck in transition when module is disabled. +* Pins are activated in c_can_start() and deactivated +* in c_can_stop() +*/ + s =pinctrl_lookup_state (pinctrl,PINCTRL_STATE_SLEEP ); +if (!IS_ERR (s)) +pinctrl_select_state (pinctrl, s); + }else { +dev_warn (&pdev->dev, +"failed to get pinctrl\n" ); + } +/* get the appropriate clk */ clk =devm_clk_get (&pdev->dev,NULL );if (IS_ERR (clk)) {
@@ -271,6 +290,7 @@ static int c_can_plat_probe(struct platform_device *pdev) priv =netdev_priv (dev); priv->drvdata = drvdata; + priv->pinctrl = pinctrl;switch (drvdata->id) {case BOSCH_C_CAN :
Signature · 1 line
1.8.3.2
Marc Kleine-Budde
maintainerRe: [PATCH v3 6/8] net: can: c_can: Disable pins when CAN interface is down
Quoted 29 lines · Roger Quadros
DRA7 CAN IP suffers from a problem which causes it to be prevented from fully turning OFF (i.e. stuck in transition) if the module was disabled while there was traffic on the
CAN_RXline.To work around this issue we select the SLEEP pin state by default on probe and use the DEFAULT pin state on CAN up and back to the SLEEP pin state on CAN down.
Signed-off-by Roger Quadros <[email protected]>--- drivers/net/can/c_can/c_can.c | 20 ++++++++++++++++++++ drivers/net/can/c_can/c_can.h | 1 + drivers/net/can/c_can/c_can_platform.c | 20 ++++++++++++++++++++ 3 files changed, 41 insertions(+)drivers/net/can/c_can/c_can.c +1
-0@@ -35,6 +35,7 @@#include <linux/list.h> #include <linux/io.h> #include <linux/pm_runtime.h> +#include <linux/pinctrl/consumer.h> #include <linux/can.h> #include <linux/can/dev.h> @@ -603,6 +604,15 @@ static int c_can_start(struct net_device *dev)
drivers/net/can/c_can/c_can.c static int c_can_start(struct net_device *dev) · line 614
Quoted 10 lines
drivers/net/can/c_can/c_can.c +8
-0priv->can.state =CAN_STATE_ERROR_ACTIVE ; +/* activate pins */ +if (!IS_ERR (priv->pinctrl)) { +struct pinctrl_state *s; + + s =pinctrl_lookup_state (priv->pinctrl,PINCTRL_STATE_DEFAULT ); +if (!IS_ERR (s)) +pinctrl_select_state (priv->pinctrl, s); + }
Can you factor this into a common function? Which is used like this:
c_can_pinctrl_select_state(priv, PINCTRL_STATE_DEFAULT)
Otherwise looks god.
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
Re: [PATCH v3 6/8] net: can: c_can: Disable pins when CAN interface is down
Quoted 43 lines · Marc Kleine-Budde
Quoted 29 lines · Roger Quadros
DRA7 CAN IP suffers from a problem which causes it to be prevented from fully turning OFF (i.e. stuck in transition) if the module was disabled while there was traffic on the
CAN_RXline.To work around this issue we select the SLEEP pin state by default on probe and use the DEFAULT pin state on CAN up and back to the SLEEP pin state on CAN down.
Signed-off-by Roger Quadros <[email protected]>--- drivers/net/can/c_can/c_can.c | 20 ++++++++++++++++++++ drivers/net/can/c_can/c_can.h | 1 + drivers/net/can/c_can/c_can_platform.c | 20 ++++++++++++++++++++ 3 files changed, 41 insertions(+)drivers/net/can/c_can/c_can.c +1
-0@@ -35,6 +35,7 @@#include <linux/list.h> #include <linux/io.h> #include <linux/pm_runtime.h> +#include <linux/pinctrl/consumer.h> #include <linux/can.h> #include <linux/can/dev.h> @@ -603,6 +604,15 @@ static int c_can_start(struct net_device *dev)drivers/net/can/c_can/c_can.c static int c_can_start(struct net_device *dev) · line 614
Quoted 10 lines
drivers/net/can/c_can/c_can.c +8
-0priv->can.state =CAN_STATE_ERROR_ACTIVE ; +/* activate pins */ +if (!IS_ERR (priv->pinctrl)) { +struct pinctrl_state *s; + + s =pinctrl_lookup_state (priv->pinctrl,PINCTRL_STATE_DEFAULT ); +if (!IS_ERR (s)) +pinctrl_select_state (priv->pinctrl, s); + }Can you factor this into a common function? Which is used like this:
Quoted 3 lines
c_can_pinctrl_select_state(priv, PINCTRL_STATE_DEFAULT)Otherwise looks god.
OK.
cheers,
-roger
PATCH v3 7/8 net: can: c_can: Add support for TI DRA7 DCAN
In reply to Roger QuadrosDRA7 SoC has 2 CAN IPs. Provide compatible IDs and RAMINIT register data for both.
--- Documentation/devicetree/bindings/net/can/c_can.txt | 1 + drivers/net/can/c_can/c_can_platform.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+)
Documentation/devicetree/bindings/net/can/c_can.txt +1 -0
@@ -4,6 +4,7 @@ Bosch C_CAN/D_CAN controller Device Tree Bindings Required properties: - compatible : Should be "bosch,c_can" for C_CAN controllers and "bosch,d_can" for D_CAN controllers. + Can be "ti,dra7-d_can1" or "ti,dra7-d_can2". - reg : physical base address and size of the C_CAN/D_CAN registers map - interrupts : property with a value describing the interrupt
drivers/net/can/c_can/c_can_platform.c +16 -0
@@ -195,6 +195,20 @@ static struct c_can_driver_data d_can_drvdata = { .id = BOSCH_D_CAN, }; +static struct c_can_driver_data dra7_dcan1_drvdata = { + .id =BOSCH_D_CAN , + .raminit_start_bit =3 , + .raminit_done_bit =1 , + .raminit_pulse = true, +}; + +static struct c_can_driver_data dra7_dcan2_drvdata = { + .id =BOSCH_D_CAN , + .raminit_start_bit =5 , + .raminit_done_bit =2 , + .raminit_pulse = true, +}; +static struct platform_device_id c_can_id_table[] = { { .name =KBUILD_MODNAME ,
@@ -215,6 +229,8 @@ MODULE_DEVICE_TABLE(platform, c_can_id_table);static const struct of_device_id c_can_of_table[] = { { .compatible ="bosch,c_can" , .data = &c_can_drvdata }, { .compatible ="bosch,d_can" , .data = &d_can_drvdata }, + { .compatible ="ti,dra7-d_can1" , .data = &dra7_dcan1_drvdata }, + { .compatible ="ti,dra7-d_can2" , .data = &dra7_dcan2_drvdata }, {/* sentinel */ }, };MODULE_DEVICE_TABLE (of, c_can_of_table);
Signature · 1 line
1.8.3.2
Marc Kleine-Budde
maintainerRe: [PATCH v3 7/8] net: can: c_can: Add support for TI DRA7 DCAN
Quoted 2 lines · Roger Quadros
DRA7 SoC has 2 CAN IPs. Provide compatible IDs and RAMINIT register data for both.
My understanding of the discussion with Wolfram was:
- We should put the number of the Interface into to DT as a regmap parameter.
- We put the method how to find the correct bits into the DT, via the compatible.
So for both CAN instances on the DRA7 we have a single compatible "ti,dra7-d_can" and in the driver a mechanism that translates the number of the instance into the needed bit offsets, e.g. via two arrays.
Same comments for patch 8/8.
Marc
Quoted 54 lines
Signed-off-by Roger Quadros <[email protected]>--- Documentation/devicetree/bindings/net/can/c_can.txt | 1 + drivers/net/can/c_can/c_can_platform.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+)Documentation/devicetree/bindings/net/can/c_can.txt +1
-0@@ -4,6 +4,7 @@ Bosch C_CAN/D_CAN controller Device Tree Bindings Required properties: - compatible : Should be "bosch,c_can" for C_CAN controllers and "bosch,d_can" for D_CAN controllers. + Can be "ti,dra7-d_can1" or "ti,dra7-d_can2". - reg : physical base address and size of the C_CAN/D_CAN registers map - interrupts : property with a value describing the interruptdrivers/net/can/c_can/c_can_platform.c +16
-0@@ -195,6 +195,20 @@ static struct c_can_driver_data d_can_drvdata = { .id = BOSCH_D_CAN, }; +static struct c_can_driver_data dra7_dcan1_drvdata = { + .id =BOSCH_D_CAN , + .raminit_start_bit =3 , + .raminit_done_bit =1 , + .raminit_pulse = true, +}; + +static struct c_can_driver_data dra7_dcan2_drvdata = { + .id =BOSCH_D_CAN , + .raminit_start_bit =5 , + .raminit_done_bit =2 , + .raminit_pulse = true, +}; +static struct platform_device_id c_can_id_table[] = { { .name =KBUILD_MODNAME ,@@ -215,6 +229,8 @@ MODULE_DEVICE_TABLE(platform, c_can_id_table);static const struct of_device_id c_can_of_table[] = { { .compatible ="bosch,c_can" , .data = &c_can_drvdata }, { .compatible ="bosch,d_can" , .data = &d_can_drvdata }, + { .compatible ="ti,dra7-d_can1" , .data = &dra7_dcan1_drvdata }, + { .compatible ="ti,dra7-d_can2" , .data = &dra7_dcan2_drvdata }, {/* sentinel */ }, };MODULE_DEVICE_TABLE (of, c_can_of_table);
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
Re: [PATCH v3 7/8] net: can: c_can: Add support for TI DRA7 DCAN
Quoted 10 lines · Marc Kleine-Budde
Quoted 2 lines · Roger Quadros
DRA7 SoC has 2 CAN IPs. Provide compatible IDs and RAMINIT register data for both.
My understanding of the discussion with Wolfram was:
- We should put the number of the Interface into to DT as a regmap parameter.
- We put the method how to find the correct bits into the DT, via the compatible.
Quoted 4 lines
So for both CAN instances on the DRA7 we have a single compatible "ti,dra7-d_can" and in the driver a mechanism that translates the number of the instance into the needed bit offsets, e.g. via two arrays.
OK. I'll revise this series.
The new syscon-raminit property will be like
syscon-raminit = <syscon_phandle raminit-reg-offset dcan-interface-number>;
cheers,
-roger
Quoted 60 lines
Same comments for patch 8/8.
Marc
Quoted 54 lines
Signed-off-by Roger Quadros <[email protected]>--- Documentation/devicetree/bindings/net/can/c_can.txt | 1 + drivers/net/can/c_can/c_can_platform.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+)Documentation/devicetree/bindings/net/can/c_can.txt +1
-0@@ -4,6 +4,7 @@ Bosch C_CAN/D_CAN controller Device Tree Bindings Required properties: - compatible : Should be "bosch,c_can" for C_CAN controllers and "bosch,d_can" for D_CAN controllers. + Can be "ti,dra7-d_can1" or "ti,dra7-d_can2". - reg : physical base address and size of the C_CAN/D_CAN registers map - interrupts : property with a value describing the interruptdrivers/net/can/c_can/c_can_platform.c +16
-0@@ -195,6 +195,20 @@ static struct c_can_driver_data d_can_drvdata = { .id = BOSCH_D_CAN, }; +static struct c_can_driver_data dra7_dcan1_drvdata = { + .id =BOSCH_D_CAN , + .raminit_start_bit =3 , + .raminit_done_bit =1 , + .raminit_pulse = true, +}; + +static struct c_can_driver_data dra7_dcan2_drvdata = { + .id =BOSCH_D_CAN , + .raminit_start_bit =5 , + .raminit_done_bit =2 , + .raminit_pulse = true, +}; +static struct platform_device_id c_can_id_table[] = { { .name =KBUILD_MODNAME ,@@ -215,6 +229,8 @@ MODULE_DEVICE_TABLE(platform, c_can_id_table);static const struct of_device_id c_can_of_table[] = { { .compatible ="bosch,c_can" , .data = &c_can_drvdata }, { .compatible ="bosch,d_can" , .data = &d_can_drvdata }, + { .compatible ="ti,dra7-d_can1" , .data = &dra7_dcan1_drvdata }, + { .compatible ="ti,dra7-d_can2" , .data = &dra7_dcan2_drvdata }, {/* sentinel */ }, };MODULE_DEVICE_TABLE (of, c_can_of_table);
Marc Kleine-Budde
maintainerRe: [PATCH v3 7/8] net: can: c_can: Add support for TI DRA7 DCAN
Quoted 16 lines · Roger Quadros
Quoted 10 lines · Marc Kleine-Budde
Quoted 2 lines · Roger Quadros
DRA7 SoC has 2 CAN IPs. Provide compatible IDs and RAMINIT register data for both.
My understanding of the discussion with Wolfram was:
- We should put the number of the Interface into to DT as a regmap parameter.
- We put the method how to find the correct bits into the DT, via the compatible.Quoted 4 lines
So for both CAN instances on the DRA7 we have a single compatible "ti,dra7-d_can" and in the driver a mechanism that translates the number of the instance into the needed bit offsets, e.g. via two arrays.
Quoted 4 lines
OK. I'll revise this series.
The new syscon-raminit property will be like
syscon-raminit = <syscon_phandleraminit-reg-offset dcan-interface-number>;
Yes. Wolfram?
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
PATCH v3 8/8 net: can: c_can: Add support for TI am3352 DCAN
In reply to Roger QuadrosAM3352 SoC has 2 DCAN modules. Add compatible id and raminit driver data for am3352 DCAN.
--- Documentation/devicetree/bindings/net/can/c_can.txt | 3 ++- drivers/net/can/c_can/c_can_platform.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/can/c_can.txt +2 -1
@@ -4,7 +4,8 @@ Bosch C_CAN/D_CAN controller Device Tree Bindings Required properties: - compatible : Should be "bosch,c_can" for C_CAN controllers and "bosch,d_can" for D_CAN controllers. - Can be "ti,dra7-d_can1" or "ti,dra7-d_can2". + Can be "ti,dra7-d_can1" or "ti,dra7-d_can2" or + "ti,am3352-d_can0" or "ti,am3352-d_can1". - reg : physical base address and size of the C_CAN/D_CAN registers map - interrupts : property with a value describing the interrupt
drivers/net/can/c_can/c_can_platform.c +14 -0
@@ -209,6 +209,18 @@ static struct c_can_driver_data dra7_dcan2_drvdata = { .raminit_pulse = true, }; +static struct c_can_driver_data am3352_dcan0_drvdata = { + .id =BOSCH_D_CAN , + .raminit_start_bit =0 , + .raminit_done_bit =8 , +}; + +static struct c_can_driver_data am3352_dcan1_drvdata = { + .id =BOSCH_D_CAN , + .raminit_start_bit =1 , + .raminit_done_bit =9 , +}; +static struct platform_device_id c_can_id_table[] = { { .name =KBUILD_MODNAME ,
@@ -231,6 +243,8 @@ static const struct of_device_id c_can_of_table[] = { { .compatible = "bosch,d_can", .data = &d_can_drvdata }, { .compatible = "ti,dra7-d_can1", .data = &dra7_dcan1_drvdata }, { .compatible = "ti,dra7-d_can2", .data = &dra7_dcan2_drvdata }, + { .compatible = "ti,am3352-d_can0", .data = &am3352_dcan0_drvdata }, + { .compatible = "ti,am3352-d_can1", .data = &am3352_dcan1_drvdata }, { /* sentinel */ }, };MODULE_DEVICE_TABLE (of, c_can_of_table);
Signature · 1 line
1.8.3.2