|
38 | 38 |
|
39 | 39 | #include "c_can.h" |
40 | 40 |
|
| 41 | +#define CAN_RAMINIT_START_MASK(i) (1 << (i)) |
| 42 | + |
41 | 43 | /* |
42 | 44 | * 16-bit c_can registers can be arranged differently in the memory |
43 | 45 | * architecture of different implementations. For example: 16-bit |
@@ -68,6 +70,18 @@ static void c_can_plat_write_reg_aligned_to_32bit(struct c_can_priv *priv, |
68 | 70 | writew(val, priv->base + 2 * priv->regs[index]); |
69 | 71 | } |
70 | 72 |
|
| 73 | +static void c_can_hw_raminit(const struct c_can_priv *priv, bool enable) |
| 74 | +{ |
| 75 | + u32 val; |
| 76 | + |
| 77 | + val = readl(priv->raminit_ctrlreg); |
| 78 | + if (enable) |
| 79 | + val |= CAN_RAMINIT_START_MASK(priv->instance); |
| 80 | + else |
| 81 | + val &= ~CAN_RAMINIT_START_MASK(priv->instance); |
| 82 | + writel(val, priv->raminit_ctrlreg); |
| 83 | +} |
| 84 | + |
71 | 85 | static struct platform_device_id c_can_id_table[] = { |
72 | 86 | [BOSCH_C_CAN_PLATFORM] = { |
73 | 87 | .name = KBUILD_MODNAME, |
@@ -99,7 +113,7 @@ static int __devinit c_can_plat_probe(struct platform_device *pdev) |
99 | 113 | const struct of_device_id *match; |
100 | 114 | const struct platform_device_id *id; |
101 | 115 | struct pinctrl *pinctrl; |
102 | | - struct resource *mem; |
| 116 | + struct resource *mem, *res; |
103 | 117 | int irq; |
104 | 118 | struct clk *clk; |
105 | 119 |
|
@@ -178,6 +192,18 @@ static int __devinit c_can_plat_probe(struct platform_device *pdev) |
178 | 192 | priv->can.ctrlmode_supported |= CAN_CTRLMODE_3_SAMPLES; |
179 | 193 | priv->read_reg = c_can_plat_read_reg_aligned_to_16bit; |
180 | 194 | priv->write_reg = c_can_plat_write_reg_aligned_to_16bit; |
| 195 | + |
| 196 | + if (pdev->dev.of_node) |
| 197 | + priv->instance = of_alias_get_id(pdev->dev.of_node, "d_can"); |
| 198 | + else |
| 199 | + priv->instance = pdev->id; |
| 200 | + |
| 201 | + res = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
| 202 | + priv->raminit_ctrlreg = devm_request_and_ioremap(&pdev->dev, res); |
| 203 | + if (!priv->raminit_ctrlreg || priv->instance < 0) |
| 204 | + dev_info(&pdev->dev, "control memory is not used for raminit\n"); |
| 205 | + else |
| 206 | + priv->raminit = c_can_hw_raminit; |
181 | 207 | break; |
182 | 208 | default: |
183 | 209 | ret = -EINVAL; |
|
0 commit comments