Lines Matching +full:cs +full:- +full:number

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2010 - 2013 Texas Instruments Incorporated. http://www.ti.com/
8 * Murali Karicheri <m-karicheri2@ti.com>
83 * struct aemif_cs_data: structure to hold cs parameters
84 * @cs: chip-select number
97 u8 cs; member
115 * @num_cs: number of assigned chip-selects
116 * @cs_offset: start number of cs nodes
117 * @cs_data: array of chip-select settings
129 * aemif_calc_rate - calculate timing data.
143 result = DIV_ROUND_UP((wanted * clk), NSEC_PER_MSEC) - 1; in aemif_calc_rate()
145 dev_dbg(&pdev->dev, "%s: result %d from %ld, %d\n", __func__, result, in aemif_calc_rate()
154 result = -EINVAL; in aemif_calc_rate()
160 * aemif_config_abus - configure async bus parameters
162 * @csnum: aemif chip select number
169 * chip-select.
176 struct aemif_cs_data *data = &aemif->cs_data[csnum]; in aemif_config_abus()
178 unsigned long clk_rate = aemif->clk_rate; in aemif_config_abus()
182 offset = A1CR_OFFSET + (data->cs - aemif->cs_offset) * 4; in aemif_config_abus()
184 ta = aemif_calc_rate(pdev, data->ta, clk_rate, TA_MAX); in aemif_config_abus()
185 rhold = aemif_calc_rate(pdev, data->rhold, clk_rate, RHOLD_MAX); in aemif_config_abus()
186 rstrobe = aemif_calc_rate(pdev, data->rstrobe, clk_rate, RSTROBE_MAX); in aemif_config_abus()
187 rsetup = aemif_calc_rate(pdev, data->rsetup, clk_rate, RSETUP_MAX); in aemif_config_abus()
188 whold = aemif_calc_rate(pdev, data->whold, clk_rate, WHOLD_MAX); in aemif_config_abus()
189 wstrobe = aemif_calc_rate(pdev, data->wstrobe, clk_rate, WSTROBE_MAX); in aemif_config_abus()
190 wsetup = aemif_calc_rate(pdev, data->wsetup, clk_rate, WSETUP_MAX); in aemif_config_abus()
194 dev_err(&pdev->dev, "%s: cannot get suitable timings\n", in aemif_config_abus()
196 return -EINVAL; in aemif_config_abus()
202 set |= (data->asize & ACR_ASIZE_MASK); in aemif_config_abus()
203 if (data->enable_ew) in aemif_config_abus()
205 if (data->enable_ss) in aemif_config_abus()
208 val = readl(aemif->base + offset); in aemif_config_abus()
211 writel(val, aemif->base + offset); in aemif_config_abus()
222 * aemif_get_hw_params - function to read hw register values
224 * @csnum: aemif chip select number
233 struct aemif_cs_data *data = &aemif->cs_data[csnum]; in aemif_get_hw_params()
234 unsigned long clk_rate = aemif->clk_rate; in aemif_get_hw_params()
237 offset = A1CR_OFFSET + (data->cs - aemif->cs_offset) * 4; in aemif_get_hw_params()
238 val = readl(aemif->base + offset); in aemif_get_hw_params()
240 data->ta = aemif_cycles_to_nsec(TA_VAL(val), clk_rate); in aemif_get_hw_params()
241 data->rhold = aemif_cycles_to_nsec(RHOLD_VAL(val), clk_rate); in aemif_get_hw_params()
242 data->rstrobe = aemif_cycles_to_nsec(RSTROBE_VAL(val), clk_rate); in aemif_get_hw_params()
243 data->rsetup = aemif_cycles_to_nsec(RSETUP_VAL(val), clk_rate); in aemif_get_hw_params()
244 data->whold = aemif_cycles_to_nsec(WHOLD_VAL(val), clk_rate); in aemif_get_hw_params()
245 data->wstrobe = aemif_cycles_to_nsec(WSTROBE_VAL(val), clk_rate); in aemif_get_hw_params()
246 data->wsetup = aemif_cycles_to_nsec(WSETUP_VAL(val), clk_rate); in aemif_get_hw_params()
247 data->enable_ew = EW_VAL(val); in aemif_get_hw_params()
248 data->enable_ss = SSTROBE_VAL(val); in aemif_get_hw_params()
249 data->asize = val & ASIZE_MAX; in aemif_get_hw_params()
253 * of_aemif_parse_abus_config - parse CS configuration from DT
258 * configured in a cs device binding node.
265 u32 cs; in of_aemif_parse_abus_config() local
268 if (of_property_read_u32(np, "ti,cs-chipselect", &cs)) { in of_aemif_parse_abus_config()
269 dev_dbg(&pdev->dev, "cs property is required"); in of_aemif_parse_abus_config()
270 return -EINVAL; in of_aemif_parse_abus_config()
273 if (cs - aemif->cs_offset >= NUM_CS || cs < aemif->cs_offset) { in of_aemif_parse_abus_config()
274 dev_dbg(&pdev->dev, "cs number is incorrect %d", cs); in of_aemif_parse_abus_config()
275 return -EINVAL; in of_aemif_parse_abus_config()
278 if (aemif->num_cs >= NUM_CS) { in of_aemif_parse_abus_config()
279 dev_dbg(&pdev->dev, "cs count is more than %d", NUM_CS); in of_aemif_parse_abus_config()
280 return -EINVAL; in of_aemif_parse_abus_config()
283 data = &aemif->cs_data[aemif->num_cs]; in of_aemif_parse_abus_config()
284 data->cs = cs; in of_aemif_parse_abus_config()
287 aemif_get_hw_params(pdev, aemif->num_cs++); in of_aemif_parse_abus_config()
290 if (!of_property_read_u32(np, "ti,cs-min-turnaround-ns", &val)) in of_aemif_parse_abus_config()
291 data->ta = val; in of_aemif_parse_abus_config()
293 if (!of_property_read_u32(np, "ti,cs-read-hold-ns", &val)) in of_aemif_parse_abus_config()
294 data->rhold = val; in of_aemif_parse_abus_config()
296 if (!of_property_read_u32(np, "ti,cs-read-strobe-ns", &val)) in of_aemif_parse_abus_config()
297 data->rstrobe = val; in of_aemif_parse_abus_config()
299 if (!of_property_read_u32(np, "ti,cs-read-setup-ns", &val)) in of_aemif_parse_abus_config()
300 data->rsetup = val; in of_aemif_parse_abus_config()
302 if (!of_property_read_u32(np, "ti,cs-write-hold-ns", &val)) in of_aemif_parse_abus_config()
303 data->whold = val; in of_aemif_parse_abus_config()
305 if (!of_property_read_u32(np, "ti,cs-write-strobe-ns", &val)) in of_aemif_parse_abus_config()
306 data->wstrobe = val; in of_aemif_parse_abus_config()
308 if (!of_property_read_u32(np, "ti,cs-write-setup-ns", &val)) in of_aemif_parse_abus_config()
309 data->wsetup = val; in of_aemif_parse_abus_config()
311 if (!of_property_read_u32(np, "ti,cs-bus-width", &val)) in of_aemif_parse_abus_config()
313 data->asize = 1; in of_aemif_parse_abus_config()
314 data->enable_ew = of_property_read_bool(np, "ti,cs-extended-wait-mode"); in of_aemif_parse_abus_config()
315 data->enable_ss = of_property_read_bool(np, "ti,cs-select-strobe-mode"); in of_aemif_parse_abus_config()
320 { .compatible = "ti,davinci-aemif", },
321 { .compatible = "ti,da850-aemif", },
329 int ret = -ENODEV; in aemif_probe()
330 struct device *dev = &pdev->dev; in aemif_probe()
331 struct device_node *np = dev->of_node; in aemif_probe()
336 return -ENOMEM; in aemif_probe()
340 aemif->clk = devm_clk_get_enabled(dev, NULL); in aemif_probe()
341 if (IS_ERR(aemif->clk)) in aemif_probe()
342 return dev_err_probe(dev, PTR_ERR(aemif->clk), in aemif_probe()
345 aemif->clk_rate = clk_get_rate(aemif->clk) / MSEC_PER_SEC; in aemif_probe()
347 if (np && of_device_is_compatible(np, "ti,da850-aemif")) in aemif_probe()
348 aemif->cs_offset = 2; in aemif_probe()
350 aemif->base = devm_platform_ioremap_resource(pdev, 0); in aemif_probe()
351 if (IS_ERR(aemif->base)) in aemif_probe()
352 return PTR_ERR(aemif->base); in aemif_probe()
356 * For every controller device node, there is a cs device node in aemif_probe()
358 * functions iterate over these nodes and update the cs data in aemif_probe()
368 for (i = 0; i < aemif->num_cs; i++) { in aemif_probe()
372 aemif->cs_data[i].cs); in aemif_probe()
395 .name = "ti-aemif",
402 MODULE_AUTHOR("Murali Karicheri <m-karicheri2@ti.com>");