22 * Marvell EBU SoC Device Bus Controller
33 * (memory controller for NOR/NAND/SRAM/FPGA devices)
44 *
5- * Copyright (C) 2013 Marvell
5+ * Copyright (C) 2013-2014 Marvell
66 *
77 * This program is free software: you can redistribute it and/or modify
88 * it under the terms of the GNU General Public License as published by
4444#define ARMADA_READ_PARAM_OFFSET 0x0
4545#define ARMADA_WRITE_PARAM_OFFSET 0x4
4646
47+ #define ORION_RESERVED (0x2 << 30)
48+ #define ORION_BADR_SKEW_SHIFT 28
49+ #define ORION_WR_HIGH_EXT_BIT BIT(27)
50+ #define ORION_WR_HIGH_EXT_MASK 0x8
51+ #define ORION_WR_LOW_EXT_BIT BIT(26)
52+ #define ORION_WR_LOW_EXT_MASK 0x8
53+ #define ORION_ALE_WR_EXT_BIT BIT(25)
54+ #define ORION_ALE_WR_EXT_MASK 0x8
55+ #define ORION_ACC_NEXT_EXT_BIT BIT(24)
56+ #define ORION_ACC_NEXT_EXT_MASK 0x10
57+ #define ORION_ACC_FIRST_EXT_BIT BIT(23)
58+ #define ORION_ACC_FIRST_EXT_MASK 0x10
59+ #define ORION_TURN_OFF_EXT_BIT BIT(22)
60+ #define ORION_TURN_OFF_EXT_MASK 0x8
61+ #define ORION_DEV_WIDTH_SHIFT 20
62+ #define ORION_WR_HIGH_SHIFT 17
63+ #define ORION_WR_HIGH_MASK 0x7
64+ #define ORION_WR_LOW_SHIFT 14
65+ #define ORION_WR_LOW_MASK 0x7
66+ #define ORION_ALE_WR_SHIFT 11
67+ #define ORION_ALE_WR_MASK 0x7
68+ #define ORION_ACC_NEXT_SHIFT 7
69+ #define ORION_ACC_NEXT_MASK 0xF
70+ #define ORION_ACC_FIRST_SHIFT 3
71+ #define ORION_ACC_FIRST_MASK 0xF
72+ #define ORION_TURN_OFF_SHIFT 0
73+ #define ORION_TURN_OFF_MASK 0x7
74+
4775struct devbus_read_params {
4876 u32 bus_width ;
4977 u32 badr_skew ;
@@ -96,7 +124,6 @@ static int devbus_get_timing_params(struct devbus *devbus,
96124{
97125 int err ;
98126
99- /* Get read timings */
100127 err = of_property_read_u32 (node , "devbus,bus-width" , & r -> bus_width );
101128 if (err < 0 ) {
102129 dev_err (devbus -> dev ,
@@ -138,24 +165,25 @@ static int devbus_get_timing_params(struct devbus *devbus,
138165 if (err < 0 )
139166 return err ;
140167
141- err = get_timing_param_ps (devbus , node , "devbus,rd-setup-ps" ,
142- & r -> rd_setup );
143- if (err < 0 )
144- return err ;
145-
146- err = get_timing_param_ps (devbus , node , "devbus,rd-hold-ps" ,
147- & r -> rd_hold );
148- if (err < 0 )
149- return err ;
150-
151- /* Get write timings */
152- err = of_property_read_u32 (node , "devbus,sync-enable" ,
153- & w -> sync_enable );
154- if (err < 0 ) {
155- dev_err (devbus -> dev ,
156- "%s has no 'devbus,sync-enable' property\n" ,
157- node -> full_name );
158- return err ;
168+ if (of_device_is_compatible (devbus -> dev -> of_node , "marvell,mvebu-devbus" )) {
169+ err = get_timing_param_ps (devbus , node , "devbus,rd-setup-ps" ,
170+ & r -> rd_setup );
171+ if (err < 0 )
172+ return err ;
173+
174+ err = get_timing_param_ps (devbus , node , "devbus,rd-hold-ps" ,
175+ & r -> rd_hold );
176+ if (err < 0 )
177+ return err ;
178+
179+ err = of_property_read_u32 (node , "devbus,sync-enable" ,
180+ & w -> sync_enable );
181+ if (err < 0 ) {
182+ dev_err (devbus -> dev ,
183+ "%s has no 'devbus,sync-enable' property\n" ,
184+ node -> full_name );
185+ return err ;
186+ }
159187 }
160188
161189 err = get_timing_param_ps (devbus , node , "devbus,ale-wr-ps" ,
@@ -176,6 +204,39 @@ static int devbus_get_timing_params(struct devbus *devbus,
176204 return 0 ;
177205}
178206
207+ static void devbus_orion_set_timing_params (struct devbus * devbus ,
208+ struct device_node * node ,
209+ struct devbus_read_params * r ,
210+ struct devbus_write_params * w )
211+ {
212+ u32 value ;
213+
214+ /*
215+ * The hardware designers found it would be a good idea to
216+ * split most of the values in the register into two fields:
217+ * one containing all the low-order bits, and another one
218+ * containing just the high-order bit. For all of those
219+ * fields, we have to split the value into these two parts.
220+ */
221+ value = (r -> turn_off & ORION_TURN_OFF_MASK ) << ORION_TURN_OFF_SHIFT |
222+ (r -> acc_first & ORION_ACC_FIRST_MASK ) << ORION_ACC_FIRST_SHIFT |
223+ (r -> acc_next & ORION_ACC_NEXT_MASK ) << ORION_ACC_NEXT_SHIFT |
224+ (w -> ale_wr & ORION_ALE_WR_MASK ) << ORION_ALE_WR_SHIFT |
225+ (w -> wr_low & ORION_WR_LOW_MASK ) << ORION_WR_LOW_SHIFT |
226+ (w -> wr_high & ORION_WR_HIGH_MASK ) << ORION_WR_HIGH_SHIFT |
227+ r -> bus_width << ORION_DEV_WIDTH_SHIFT |
228+ ((r -> turn_off & ORION_TURN_OFF_EXT_MASK ) ? ORION_TURN_OFF_EXT_BIT : 0 ) |
229+ ((r -> acc_first & ORION_ACC_FIRST_EXT_MASK ) ? ORION_ACC_FIRST_EXT_BIT : 0 ) |
230+ ((r -> acc_next & ORION_ACC_NEXT_EXT_MASK ) ? ORION_ACC_NEXT_EXT_BIT : 0 ) |
231+ ((w -> ale_wr & ORION_ALE_WR_EXT_MASK ) ? ORION_ALE_WR_EXT_BIT : 0 ) |
232+ ((w -> wr_low & ORION_WR_LOW_EXT_MASK ) ? ORION_WR_LOW_EXT_BIT : 0 ) |
233+ ((w -> wr_high & ORION_WR_HIGH_EXT_MASK ) ? ORION_WR_HIGH_EXT_BIT : 0 ) |
234+ (r -> badr_skew << ORION_BADR_SKEW_SHIFT ) |
235+ ORION_RESERVED ;
236+
237+ writel (value , devbus -> base );
238+ }
239+
179240static void devbus_armada_set_timing_params (struct devbus * devbus ,
180241 struct device_node * node ,
181242 struct devbus_read_params * r ,
@@ -255,7 +316,10 @@ static int mvebu_devbus_probe(struct platform_device *pdev)
255316 return err ;
256317
257318 /* Set the new timing parameters */
258- devbus_armada_set_timing_params (devbus , node , & r , & w );
319+ if (of_device_is_compatible (node , "marvell,orion-devbus" ))
320+ devbus_orion_set_timing_params (devbus , node , & r , & w );
321+ else
322+ devbus_armada_set_timing_params (devbus , node , & r , & w );
259323
260324 /*
261325 * We need to create a child device explicitly from here to
@@ -271,6 +335,7 @@ static int mvebu_devbus_probe(struct platform_device *pdev)
271335
272336static const struct of_device_id mvebu_devbus_of_match [] = {
273337 { .compatible = "marvell,mvebu-devbus" },
338+ { .compatible = "marvell,orion-devbus" },
274339 {},
275340};
276341MODULE_DEVICE_TABLE (of , mvebu_devbus_of_match );
0 commit comments