Lines Matching +full:sync +full:- +full:clk +full:- +full:ps

1 // SPDX-License-Identifier: GPL-2.0-only
6 * Copyright (C) 2013-2014 Marvell
14 #include <linux/clk.h>
96 dev_err(devbus->dev, "%pOF has no '%s' property\n", in get_timing_param_ps()
101 *ticks = (time_ps + devbus->tick_ps - 1) / devbus->tick_ps; in get_timing_param_ps()
103 dev_dbg(devbus->dev, "%s: %u ps -> 0x%x\n", in get_timing_param_ps()
115 err = of_property_read_u32(node, "devbus,bus-width", &r->bus_width); in devbus_get_timing_params()
117 dev_err(devbus->dev, in devbus_get_timing_params()
118 "%pOF has no 'devbus,bus-width' property\n", in devbus_get_timing_params()
127 if (r->bus_width == 8) { in devbus_get_timing_params()
128 r->bus_width = 0; in devbus_get_timing_params()
129 } else if (r->bus_width == 16) { in devbus_get_timing_params()
130 r->bus_width = 1; in devbus_get_timing_params()
132 dev_err(devbus->dev, "invalid bus width %d\n", r->bus_width); in devbus_get_timing_params()
133 return -EINVAL; in devbus_get_timing_params()
136 err = get_timing_param_ps(devbus, node, "devbus,badr-skew-ps", in devbus_get_timing_params()
137 &r->badr_skew); in devbus_get_timing_params()
141 err = get_timing_param_ps(devbus, node, "devbus,turn-off-ps", in devbus_get_timing_params()
142 &r->turn_off); in devbus_get_timing_params()
146 err = get_timing_param_ps(devbus, node, "devbus,acc-first-ps", in devbus_get_timing_params()
147 &r->acc_first); in devbus_get_timing_params()
151 err = get_timing_param_ps(devbus, node, "devbus,acc-next-ps", in devbus_get_timing_params()
152 &r->acc_next); in devbus_get_timing_params()
156 if (of_device_is_compatible(devbus->dev->of_node, "marvell,mvebu-devbus")) { in devbus_get_timing_params()
157 err = get_timing_param_ps(devbus, node, "devbus,rd-setup-ps", in devbus_get_timing_params()
158 &r->rd_setup); in devbus_get_timing_params()
162 err = get_timing_param_ps(devbus, node, "devbus,rd-hold-ps", in devbus_get_timing_params()
163 &r->rd_hold); in devbus_get_timing_params()
167 err = of_property_read_u32(node, "devbus,sync-enable", in devbus_get_timing_params()
168 &w->sync_enable); in devbus_get_timing_params()
170 dev_err(devbus->dev, in devbus_get_timing_params()
171 "%pOF has no 'devbus,sync-enable' property\n", in devbus_get_timing_params()
177 err = get_timing_param_ps(devbus, node, "devbus,ale-wr-ps", in devbus_get_timing_params()
178 &w->ale_wr); in devbus_get_timing_params()
182 err = get_timing_param_ps(devbus, node, "devbus,wr-low-ps", in devbus_get_timing_params()
183 &w->wr_low); in devbus_get_timing_params()
187 err = get_timing_param_ps(devbus, node, "devbus,wr-high-ps", in devbus_get_timing_params()
188 &w->wr_high); in devbus_get_timing_params()
205 * one containing all the low-order bits, and another one in devbus_orion_set_timing_params()
206 * containing just the high-order bit. For all of those in devbus_orion_set_timing_params()
209 value = (r->turn_off & ORION_TURN_OFF_MASK) << ORION_TURN_OFF_SHIFT | in devbus_orion_set_timing_params()
210 (r->acc_first & ORION_ACC_FIRST_MASK) << ORION_ACC_FIRST_SHIFT | in devbus_orion_set_timing_params()
211 (r->acc_next & ORION_ACC_NEXT_MASK) << ORION_ACC_NEXT_SHIFT | in devbus_orion_set_timing_params()
212 (w->ale_wr & ORION_ALE_WR_MASK) << ORION_ALE_WR_SHIFT | in devbus_orion_set_timing_params()
213 (w->wr_low & ORION_WR_LOW_MASK) << ORION_WR_LOW_SHIFT | in devbus_orion_set_timing_params()
214 (w->wr_high & ORION_WR_HIGH_MASK) << ORION_WR_HIGH_SHIFT | in devbus_orion_set_timing_params()
215 r->bus_width << ORION_DEV_WIDTH_SHIFT | in devbus_orion_set_timing_params()
216 ((r->turn_off & ORION_TURN_OFF_EXT_MASK) ? ORION_TURN_OFF_EXT_BIT : 0) | in devbus_orion_set_timing_params()
217 ((r->acc_first & ORION_ACC_FIRST_EXT_MASK) ? ORION_ACC_FIRST_EXT_BIT : 0) | in devbus_orion_set_timing_params()
218 ((r->acc_next & ORION_ACC_NEXT_EXT_MASK) ? ORION_ACC_NEXT_EXT_BIT : 0) | in devbus_orion_set_timing_params()
219 ((w->ale_wr & ORION_ALE_WR_EXT_MASK) ? ORION_ALE_WR_EXT_BIT : 0) | in devbus_orion_set_timing_params()
220 ((w->wr_low & ORION_WR_LOW_EXT_MASK) ? ORION_WR_LOW_EXT_BIT : 0) | in devbus_orion_set_timing_params()
221 ((w->wr_high & ORION_WR_HIGH_EXT_MASK) ? ORION_WR_HIGH_EXT_BIT : 0) | in devbus_orion_set_timing_params()
222 (r->badr_skew << ORION_BADR_SKEW_SHIFT) | in devbus_orion_set_timing_params()
225 writel(value, devbus->base); in devbus_orion_set_timing_params()
236 value = r->bus_width << ARMADA_DEV_WIDTH_SHIFT | in devbus_armada_set_timing_params()
237 r->badr_skew << ARMADA_BADR_SKEW_SHIFT | in devbus_armada_set_timing_params()
238 r->rd_hold << ARMADA_RD_HOLD_SHIFT | in devbus_armada_set_timing_params()
239 r->acc_next << ARMADA_ACC_NEXT_SHIFT | in devbus_armada_set_timing_params()
240 r->rd_setup << ARMADA_RD_SETUP_SHIFT | in devbus_armada_set_timing_params()
241 r->acc_first << ARMADA_ACC_FIRST_SHIFT | in devbus_armada_set_timing_params()
242 r->turn_off; in devbus_armada_set_timing_params()
244 dev_dbg(devbus->dev, "read parameters register 0x%p = 0x%x\n", in devbus_armada_set_timing_params()
245 devbus->base + ARMADA_READ_PARAM_OFFSET, in devbus_armada_set_timing_params()
248 writel(value, devbus->base + ARMADA_READ_PARAM_OFFSET); in devbus_armada_set_timing_params()
251 value = w->sync_enable << ARMADA_SYNC_ENABLE_SHIFT | in devbus_armada_set_timing_params()
252 w->wr_low << ARMADA_WR_LOW_SHIFT | in devbus_armada_set_timing_params()
253 w->wr_high << ARMADA_WR_HIGH_SHIFT | in devbus_armada_set_timing_params()
254 w->ale_wr; in devbus_armada_set_timing_params()
256 dev_dbg(devbus->dev, "write parameters register: 0x%p = 0x%x\n", in devbus_armada_set_timing_params()
257 devbus->base + ARMADA_WRITE_PARAM_OFFSET, in devbus_armada_set_timing_params()
260 writel(value, devbus->base + ARMADA_WRITE_PARAM_OFFSET); in devbus_armada_set_timing_params()
265 struct device *dev = &pdev->dev; in mvebu_devbus_probe()
266 struct device_node *node = pdev->dev.of_node; in mvebu_devbus_probe()
270 struct clk *clk; in mvebu_devbus_probe() local
274 devbus = devm_kzalloc(&pdev->dev, sizeof(struct devbus), GFP_KERNEL); in mvebu_devbus_probe()
276 return -ENOMEM; in mvebu_devbus_probe()
278 devbus->dev = dev; in mvebu_devbus_probe()
279 devbus->base = devm_platform_ioremap_resource(pdev, 0); in mvebu_devbus_probe()
280 if (IS_ERR(devbus->base)) in mvebu_devbus_probe()
281 return PTR_ERR(devbus->base); in mvebu_devbus_probe()
283 clk = devm_clk_get_enabled(&pdev->dev, NULL); in mvebu_devbus_probe()
284 if (IS_ERR(clk)) in mvebu_devbus_probe()
285 return PTR_ERR(clk); in mvebu_devbus_probe()
292 rate = clk_get_rate(clk) / 1000; in mvebu_devbus_probe()
293 devbus->tick_ps = 1000000000 / rate; in mvebu_devbus_probe()
295 dev_dbg(devbus->dev, "Setting timing parameter, tick is %lu ps\n", in mvebu_devbus_probe()
296 devbus->tick_ps); in mvebu_devbus_probe()
298 if (!of_property_read_bool(node, "devbus,keep-config")) { in mvebu_devbus_probe()
305 if (of_device_is_compatible(node, "marvell,orion-devbus")) in mvebu_devbus_probe()
324 { .compatible = "marvell,mvebu-devbus" },
325 { .compatible = "marvell,orion-devbus" },
333 .name = "mvebu-devbus",
344 MODULE_AUTHOR("Ezequiel Garcia <ezequiel.garcia@free-electrons.com>");