• Home
  • Raw
  • Download

Lines Matching +full:cs +full:- +full:x

4  * Copyright (C) 2010 - 2013 Texas Instruments Incorporated. http://www.ti.com/
7 * Murali Karicheri <m-karicheri2@ti.com>
23 #include <linux/platform_data/ti-aemif.h>
35 #define TA(x) ((x) << TA_SHIFT) argument
36 #define RHOLD(x) ((x) << RHOLD_SHIFT) argument
37 #define RSTROBE(x) ((x) << RSTROBE_SHIFT) argument
38 #define RSETUP(x) ((x) << RSETUP_SHIFT) argument
39 #define WHOLD(x) ((x) << WHOLD_SHIFT) argument
40 #define WSTROBE(x) ((x) << WSTROBE_SHIFT) argument
41 #define WSETUP(x) ((x) << WSETUP_SHIFT) argument
42 #define EW(x) ((x) << EW_SHIFT) argument
43 #define SS(x) ((x) << SS_SHIFT) argument
57 #define TA_VAL(x) (((x) & TA(TA_MAX)) >> TA_SHIFT) argument
58 #define RHOLD_VAL(x) (((x) & RHOLD(RHOLD_MAX)) >> RHOLD_SHIFT) argument
59 #define RSTROBE_VAL(x) (((x) & RSTROBE(RSTROBE_MAX)) >> RSTROBE_SHIFT) argument
60 #define RSETUP_VAL(x) (((x) & RSETUP(RSETUP_MAX)) >> RSETUP_SHIFT) argument
61 #define WHOLD_VAL(x) (((x) & WHOLD(WHOLD_MAX)) >> WHOLD_SHIFT) argument
62 #define WSTROBE_VAL(x) (((x) & WSTROBE(WSTROBE_MAX)) >> WSTROBE_SHIFT) argument
63 #define WSETUP_VAL(x) (((x) & WSETUP(WSETUP_MAX)) >> WSETUP_SHIFT) argument
64 #define EW_VAL(x) (((x) & EW(EW_MAX)) >> EW_SHIFT) argument
65 #define SS_VAL(x) (((x) & SS(SS_MAX)) >> SS_SHIFT) argument
87 * struct aemif_cs_data: structure to hold cs parameters
88 * @cs: chip-select number
101 u8 cs; member
119 * @num_cs: number of assigned chip-selects
120 * @cs_offset: start number of cs nodes
121 * @cs_data: array of chip-select settings
133 * aemif_calc_rate - calculate timing data.
147 result = DIV_ROUND_UP((wanted * clk), NSEC_PER_MSEC) - 1; in aemif_calc_rate()
149 dev_dbg(&pdev->dev, "%s: result %d from %ld, %d\n", __func__, result, in aemif_calc_rate()
158 result = -EINVAL; in aemif_calc_rate()
164 * aemif_config_abus - configure async bus parameters
173 * chip-select.
180 struct aemif_cs_data *data = &aemif->cs_data[csnum]; in aemif_config_abus()
182 unsigned long clk_rate = aemif->clk_rate; in aemif_config_abus()
186 offset = A1CR_OFFSET + (data->cs - aemif->cs_offset) * 4; in aemif_config_abus()
188 ta = aemif_calc_rate(pdev, data->ta, clk_rate, TA_MAX); in aemif_config_abus()
189 rhold = aemif_calc_rate(pdev, data->rhold, clk_rate, RHOLD_MAX); in aemif_config_abus()
190 rstrobe = aemif_calc_rate(pdev, data->rstrobe, clk_rate, RSTROBE_MAX); in aemif_config_abus()
191 rsetup = aemif_calc_rate(pdev, data->rsetup, clk_rate, RSETUP_MAX); in aemif_config_abus()
192 whold = aemif_calc_rate(pdev, data->whold, clk_rate, WHOLD_MAX); in aemif_config_abus()
193 wstrobe = aemif_calc_rate(pdev, data->wstrobe, clk_rate, WSTROBE_MAX); in aemif_config_abus()
194 wsetup = aemif_calc_rate(pdev, data->wsetup, clk_rate, WSETUP_MAX); in aemif_config_abus()
198 dev_err(&pdev->dev, "%s: cannot get suitable timings\n", in aemif_config_abus()
200 return -EINVAL; in aemif_config_abus()
206 set |= (data->asize & ACR_ASIZE_MASK); in aemif_config_abus()
207 if (data->enable_ew) in aemif_config_abus()
209 if (data->enable_ss) in aemif_config_abus()
212 val = readl(aemif->base + offset); in aemif_config_abus()
215 writel(val, aemif->base + offset); in aemif_config_abus()
226 * aemif_get_hw_params - function to read hw register values
237 struct aemif_cs_data *data = &aemif->cs_data[csnum]; in aemif_get_hw_params()
238 unsigned long clk_rate = aemif->clk_rate; in aemif_get_hw_params()
241 offset = A1CR_OFFSET + (data->cs - aemif->cs_offset) * 4; in aemif_get_hw_params()
242 val = readl(aemif->base + offset); in aemif_get_hw_params()
244 data->ta = aemif_cycles_to_nsec(TA_VAL(val), clk_rate); in aemif_get_hw_params()
245 data->rhold = aemif_cycles_to_nsec(RHOLD_VAL(val), clk_rate); in aemif_get_hw_params()
246 data->rstrobe = aemif_cycles_to_nsec(RSTROBE_VAL(val), clk_rate); in aemif_get_hw_params()
247 data->rsetup = aemif_cycles_to_nsec(RSETUP_VAL(val), clk_rate); in aemif_get_hw_params()
248 data->whold = aemif_cycles_to_nsec(WHOLD_VAL(val), clk_rate); in aemif_get_hw_params()
249 data->wstrobe = aemif_cycles_to_nsec(WSTROBE_VAL(val), clk_rate); in aemif_get_hw_params()
250 data->wsetup = aemif_cycles_to_nsec(WSETUP_VAL(val), clk_rate); in aemif_get_hw_params()
251 data->enable_ew = EW_VAL(val); in aemif_get_hw_params()
252 data->enable_ss = SS_VAL(val); in aemif_get_hw_params()
253 data->asize = val & ASIZE_MAX; in aemif_get_hw_params()
257 * of_aemif_parse_abus_config - parse CS configuration from DT
262 * configured in a cs device binding node.
269 u32 cs; in of_aemif_parse_abus_config() local
272 if (of_property_read_u32(np, "ti,cs-chipselect", &cs)) { in of_aemif_parse_abus_config()
273 dev_dbg(&pdev->dev, "cs property is required"); in of_aemif_parse_abus_config()
274 return -EINVAL; in of_aemif_parse_abus_config()
277 if (cs - aemif->cs_offset >= NUM_CS || cs < aemif->cs_offset) { in of_aemif_parse_abus_config()
278 dev_dbg(&pdev->dev, "cs number is incorrect %d", cs); in of_aemif_parse_abus_config()
279 return -EINVAL; in of_aemif_parse_abus_config()
282 if (aemif->num_cs >= NUM_CS) { in of_aemif_parse_abus_config()
283 dev_dbg(&pdev->dev, "cs count is more than %d", NUM_CS); in of_aemif_parse_abus_config()
284 return -EINVAL; in of_aemif_parse_abus_config()
287 data = &aemif->cs_data[aemif->num_cs]; in of_aemif_parse_abus_config()
288 data->cs = cs; in of_aemif_parse_abus_config()
291 aemif_get_hw_params(pdev, aemif->num_cs++); in of_aemif_parse_abus_config()
294 if (!of_property_read_u32(np, "ti,cs-min-turnaround-ns", &val)) in of_aemif_parse_abus_config()
295 data->ta = val; in of_aemif_parse_abus_config()
297 if (!of_property_read_u32(np, "ti,cs-read-hold-ns", &val)) in of_aemif_parse_abus_config()
298 data->rhold = val; in of_aemif_parse_abus_config()
300 if (!of_property_read_u32(np, "ti,cs-read-strobe-ns", &val)) in of_aemif_parse_abus_config()
301 data->rstrobe = val; in of_aemif_parse_abus_config()
303 if (!of_property_read_u32(np, "ti,cs-read-setup-ns", &val)) in of_aemif_parse_abus_config()
304 data->rsetup = val; in of_aemif_parse_abus_config()
306 if (!of_property_read_u32(np, "ti,cs-write-hold-ns", &val)) in of_aemif_parse_abus_config()
307 data->whold = val; in of_aemif_parse_abus_config()
309 if (!of_property_read_u32(np, "ti,cs-write-strobe-ns", &val)) in of_aemif_parse_abus_config()
310 data->wstrobe = val; in of_aemif_parse_abus_config()
312 if (!of_property_read_u32(np, "ti,cs-write-setup-ns", &val)) in of_aemif_parse_abus_config()
313 data->wsetup = val; in of_aemif_parse_abus_config()
315 if (!of_property_read_u32(np, "ti,cs-bus-width", &val)) in of_aemif_parse_abus_config()
317 data->asize = 1; in of_aemif_parse_abus_config()
318 data->enable_ew = of_property_read_bool(np, "ti,cs-extended-wait-mode"); in of_aemif_parse_abus_config()
319 data->enable_ss = of_property_read_bool(np, "ti,cs-select-strobe-mode"); in of_aemif_parse_abus_config()
324 { .compatible = "ti,davinci-aemif", },
325 { .compatible = "ti,da850-aemif", },
333 int ret = -ENODEV; in aemif_probe()
335 struct device *dev = &pdev->dev; in aemif_probe()
336 struct device_node *np = dev->of_node; in aemif_probe()
344 return -ENOMEM; in aemif_probe()
346 pdata = dev_get_platdata(&pdev->dev); in aemif_probe()
347 dev_lookup = pdata ? pdata->dev_lookup : NULL; in aemif_probe()
351 aemif->clk = devm_clk_get(dev, NULL); in aemif_probe()
352 if (IS_ERR(aemif->clk)) { in aemif_probe()
354 return PTR_ERR(aemif->clk); in aemif_probe()
357 ret = clk_prepare_enable(aemif->clk); in aemif_probe()
361 aemif->clk_rate = clk_get_rate(aemif->clk) / MSEC_PER_SEC; in aemif_probe()
363 if (np && of_device_is_compatible(np, "ti,da850-aemif")) in aemif_probe()
364 aemif->cs_offset = 2; in aemif_probe()
366 aemif->cs_offset = pdata->cs_offset; in aemif_probe()
369 aemif->base = devm_ioremap_resource(dev, res); in aemif_probe()
370 if (IS_ERR(aemif->base)) { in aemif_probe()
371 ret = PTR_ERR(aemif->base); in aemif_probe()
377 * For every controller device node, there is a cs device node in aemif_probe()
379 * functions iterate over these nodes and update the cs data in aemif_probe()
387 } else if (pdata && pdata->num_abus_data > 0) { in aemif_probe()
388 for (i = 0; i < pdata->num_abus_data; i++, aemif->num_cs++) { in aemif_probe()
389 aemif->cs_data[i].cs = pdata->abus_data[i].cs; in aemif_probe()
394 for (i = 0; i < aemif->num_cs; i++) { in aemif_probe()
398 aemif->cs_data[i].cs); in aemif_probe()
415 for (i = 0; i < pdata->num_sub_devices; i++) { in aemif_probe()
416 pdata->sub_devices[i].dev.parent = dev; in aemif_probe()
417 ret = platform_device_register(&pdata->sub_devices[i]); in aemif_probe()
420 pdata->sub_devices[i].name); in aemif_probe()
427 clk_disable_unprepare(aemif->clk); in aemif_probe()
435 clk_disable_unprepare(aemif->clk); in aemif_remove()
443 .name = "ti-aemif",
450 MODULE_AUTHOR("Murali Karicheri <m-karicheri2@ti.com>");