1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * PRU-ICSS remoteproc driver for various TI SoCs
4 *
5 * Copyright (C) 2014-2019 Texas Instruments Incorporated - http://www.ti.com/
6 * Suman Anna <s-anna@ti.com>
7 * Andrew F. Davis <afd@ti.com>
8 */
10 #include <linux/bitops.h>
11 #include <linux/debugfs.h>
12 #include <linux/interrupt.h>
13 #include <linux/mailbox_client.h>
14 #include <linux/module.h>
15 #include <linux/of_device.h>
16 #include <linux/omap-mailbox.h>
17 #include <linux/pruss.h>
18 #include <linux/pruss_driver.h>
19 #include <linux/remoteproc.h>
21 #include "remoteproc_internal.h"
22 #include "pru_rproc.h"
24 /* PRU_ICSS_PRU_CTRL registers */
25 #define PRU_CTRL_CTRL 0x0000
26 #define PRU_CTRL_STS 0x0004
27 #define PRU_CTRL_WAKEUP_EN 0x0008
28 #define PRU_CTRL_CYCLE 0x000C
29 #define PRU_CTRL_STALL 0x0010
30 #define PRU_CTRL_CTBIR0 0x0020
31 #define PRU_CTRL_CTBIR1 0x0024
32 #define PRU_CTRL_CTPPR0 0x0028
33 #define PRU_CTRL_CTPPR1 0x002C
35 /* CTRL register bit-fields */
36 #define CTRL_CTRL_SOFT_RST_N BIT(0)
37 #define CTRL_CTRL_EN BIT(1)
38 #define CTRL_CTRL_SLEEPING BIT(2)
39 #define CTRL_CTRL_CTR_EN BIT(3)
40 #define CTRL_CTRL_SINGLE_STEP BIT(8)
41 #define CTRL_CTRL_RUNSTATE BIT(15)
43 /* PRU_ICSS_PRU_DEBUG registers */
44 #define PRU_DEBUG_GPREG(x) (0x0000 + (x) * 4)
45 #define PRU_DEBUG_CT_REG(x) (0x0080 + (x) * 4)
47 /* PRU/RTU Core IRAM address masks */
48 #define PRU0_IRAM_ADDR_MASK 0x34000
49 #define PRU1_IRAM_ADDR_MASK 0x38000
50 #define RTU0_IRAM_ADDR_MASK 0x4000
51 #define RTU1_IRAM_ADDR_MASK 0x6000
53 /**
54 * enum pru_iomem - PRU core memory/register range identifiers
55 */
56 enum pru_iomem {
57 PRU_IOMEM_IRAM = 0,
58 PRU_IOMEM_CTRL,
59 PRU_IOMEM_DEBUG,
60 PRU_IOMEM_MAX,
61 };
63 /**
64 * struct pru_rproc - PRU remoteproc structure
65 * @id: id of the PRU core within the PRUSS
66 * @pruss: back-reference to parent PRUSS structure
67 * @rproc: remoteproc pointer for this PRU core
68 * @client_np: client device node
69 * @mbox: mailbox channel handle used for vring signalling with MPU
70 * @client: mailbox client to request the mailbox channel
71 * @irq_ring: IRQ number to use for processing vring buffers
72 * @irq_kick: IRQ number to use to perform virtio kick
73 * @mem_regions: data for each of the PRU memory regions
74 * @intc_config: PRU INTC configuration data
75 * @rmw_lock: lock for read, modify, write operations on registers
76 * @iram_da: device address of Instruction RAM for this PRU
77 * @pdram_da: device address of primary Data RAM for this PRU
78 * @sdram_da: device address of secondary Data RAM for this PRU
79 * @shrdram_da: device address of shared Data RAM
80 * @fw_name: name of firmware image used during loading
81 * @dt_irqs: number of irqs configured from DT
82 * @gpmux_save: saved value for gpmux config
83 * @lock: mutex to protect client usage
84 * @dbg_single_step: debug state variable to set PRU into single step mode
85 * @dbg_continuous: debug state variable to restore PRU execution mode
86 * @fw_has_intc_rsc: boolean flag to indicate INTC config through firmware
87 * @is_k3: boolean flag used to indicate the core has increased number of events
88 * @is_rtu: boolean flag to indicate the core is a RTU core
89 */
90 struct pru_rproc {
91 int id;
92 struct pruss *pruss;
93 struct rproc *rproc;
94 struct device_node *client_np;
95 struct mbox_chan *mbox;
96 struct mbox_client client;
97 int irq_vring;
98 int irq_kick;
99 struct pruss_mem_region mem_regions[PRU_IOMEM_MAX];
100 struct pruss_intc_config intc_config;
101 spinlock_t rmw_lock; /* register access lock */
102 u32 iram_da;
103 u32 pdram_da;
104 u32 sdram_da;
105 u32 shrdram_da;
106 const char *fw_name;
107 int dt_irqs;
108 u8 gpmux_save;
109 struct mutex lock; /* client access lock */
110 u32 dbg_single_step;
111 u32 dbg_continuous;
112 unsigned int fw_has_intc_rsc : 1;
113 unsigned int is_k3 : 1;
114 unsigned int is_rtu : 1;
115 };
117 static void *pru_d_da_to_va(struct pru_rproc *pru, u32 da, int len);
119 static inline u32 pru_control_read_reg(struct pru_rproc *pru, unsigned int reg)
120 {
121 return readl_relaxed(pru->mem_regions[PRU_IOMEM_CTRL].va + reg);
122 }
124 static inline
125 void pru_control_write_reg(struct pru_rproc *pru, unsigned int reg, u32 val)
126 {
127 writel_relaxed(val, pru->mem_regions[PRU_IOMEM_CTRL].va + reg);
128 }
130 static inline
131 void pru_control_set_reg(struct pru_rproc *pru, unsigned int reg,
132 u32 mask, u32 set)
133 {
134 u32 val;
135 unsigned long flags;
137 spin_lock_irqsave(&pru->rmw_lock, flags);
139 val = pru_control_read_reg(pru, reg);
140 val &= ~mask;
141 val |= (set & mask);
142 pru_control_write_reg(pru, reg, val);
144 spin_unlock_irqrestore(&pru->rmw_lock, flags);
145 }
147 /**
148 * pru_rproc_set_firmware() - set firmware for a pru core
149 * @rproc: the rproc instance of the PRU
150 * @fw_name: the new firmware name, or NULL if default is desired
151 */
152 static int pru_rproc_set_firmware(struct rproc *rproc, const char *fw_name)
153 {
154 struct pru_rproc *pru = rproc->priv;
156 if (!fw_name)
157 fw_name = pru->fw_name;
159 return rproc_set_firmware(rproc, fw_name);
160 }
162 static int pru_rproc_intc_dt_config(struct pru_rproc *pru, int index)
163 {
164 struct device *dev = &pru->rproc->dev;
165 struct device_node *np = pru->client_np;
166 struct property *prop;
167 const char *prop_name = "ti,pru-interrupt-map";
168 u8 max_system_events, max_pru_channels, max_pru_host_ints;
169 int ret = 0, i;
170 int dt_irqs;
171 u32 *arr;
172 bool has_irqs = false;
174 prop = of_find_property(np, prop_name, NULL);
175 if (!prop)
176 return 0;
178 dt_irqs = of_property_count_u32_elems(np, prop_name);
179 if (dt_irqs <= 0 || dt_irqs % 4) {
180 dev_err(dev, "bad interrupt map data %d, expected multiple of 4\n",
181 dt_irqs);
182 return -EINVAL;
183 }
185 arr = kmalloc_array(dt_irqs, sizeof(u32), GFP_KERNEL);
186 if (!arr)
187 return -ENOMEM;
189 ret = of_property_read_u32_array(np, prop_name, arr, dt_irqs);
190 if (ret) {
191 dev_err(dev, "failed to read pru irq map: %d\n", ret);
192 goto out;
193 }
195 max_system_events = pru->is_k3 ?
196 MAX_PRU_SYS_EVENTS_K3 : MAX_PRU_SYS_EVENTS;
197 max_pru_channels = pru->is_k3 ? MAX_PRU_CHANNELS_K3 : MAX_PRU_CHANNELS;
198 max_pru_host_ints = pru->is_k3 ? MAX_PRU_HOST_INT_K3 : MAX_PRU_HOST_INT;
200 for (i = 0; i < ARRAY_SIZE(pru->intc_config.sysev_to_ch); i++)
201 pru->intc_config.sysev_to_ch[i] = -1;
203 for (i = 0; i < ARRAY_SIZE(pru->intc_config.ch_to_host); i++)
204 pru->intc_config.ch_to_host[i] = -1;
206 for (i = 0; i < dt_irqs; i += 4) {
207 if (arr[i] != index)
208 continue;
210 if (arr[i + 1] < 0 ||
211 arr[i + 1] >= max_system_events) {
212 dev_err(dev, "bad sys event %d\n", arr[i + 1]);
213 ret = -EINVAL;
214 goto out;
215 }
217 if (arr[i + 2] < 0 ||
218 arr[i + 2] >= max_pru_channels) {
219 dev_err(dev, "bad channel %d\n", arr[i + 2]);
220 ret = -EINVAL;
221 goto out;
222 }
224 if (arr[i + 3] < 0 ||
225 arr[i + 3] >= max_pru_host_ints) {
226 dev_err(dev, "bad irq %d\n", arr[i + 3]);
227 ret = -EINVAL;
228 goto out;
229 }
231 pru->intc_config.sysev_to_ch[arr[i + 1]] = arr[i + 2];
232 dev_dbg(dev, "sysevt-to-ch[%d] -> %d\n", arr[i + 1],
233 arr[i + 2]);
235 pru->intc_config.ch_to_host[arr[i + 2]] = arr[i + 3];
236 dev_dbg(dev, "chnl-to-host[%d] -> %d\n", arr[i + 2],
237 arr[i + 3]);
239 has_irqs = true;
240 }
242 /*
243 * The property "ti,pru-interrupt-map" is used in a consumer node, but
244 * need not necessarily have data for all referenced PRUs. Provide a
245 * fallback to get the interrupt data from firmware for PRUs ith no
246 * interrupt data.
247 */
248 if (!has_irqs) {
249 dev_dbg(dev, "no DT irqs, falling back to firmware intc rsc mode\n");
250 goto out;
251 }
253 pru->dt_irqs = dt_irqs;
254 ret = pruss_intc_configure(pru->pruss, &pru->intc_config);
255 if (ret) {
256 dev_err(dev, "failed to configure intc %d\n", ret);
257 pru->dt_irqs = 0;
258 }
260 out:
261 kfree(arr);
263 return ret;
264 }
266 static struct rproc *__pru_rproc_get(struct device_node *np, int index)
267 {
268 struct device_node *rproc_np = NULL;
269 struct platform_device *pdev;
270 struct rproc *rproc;
272 rproc_np = of_parse_phandle(np, "prus", index);
273 if (!rproc_np || !of_device_is_available(rproc_np))
274 return ERR_PTR(-ENODEV);
276 pdev = of_find_device_by_node(rproc_np);
277 of_node_put(rproc_np);
279 if (!pdev)
280 /* probably PRU not yet probed */
281 return ERR_PTR(-EPROBE_DEFER);
283 /* TODO: replace the crude string based check to make sure it is PRU */
284 if (!strstr(dev_name(&pdev->dev), "pru") &&
285 !strstr(dev_name(&pdev->dev), "rtu")) {
286 put_device(&pdev->dev);
287 return ERR_PTR(-ENODEV);
288 }
290 rproc = platform_get_drvdata(pdev);
291 put_device(&pdev->dev);
292 if (!rproc)
293 return ERR_PTR(-EPROBE_DEFER);
295 get_device(&rproc->dev);
297 return rproc;
298 }
300 /**
301 * pru_rproc_get() - get the PRU rproc instance from a device node
302 * @np: the user/client device node
303 * @index: index to use for the prus property
304 *
305 * This function looks through a client device node's "prus" property at index
306 * @index and returns the rproc handle for a valid PRU remote processor if
307 * found. The function allows only one user to own the PRU rproc resource at
308 * a time. Caller must call pru_rproc_put() when done with using the rproc,
309 * not required if the function returns a failure.
310 *
311 * Returns the rproc handle on success, and an ERR_PTR on failure using one
312 * of the following error values
313 * -ENODEV if device is not found
314 * -EBUSY if PRU is already acquired by anyone
315 * -EPROBE_DEFER is PRU device is not probed yet
316 */
317 struct rproc *pru_rproc_get(struct device_node *np, int index)
318 {
319 struct rproc *rproc;
320 struct pru_rproc *pru;
321 const char *fw_name;
322 struct device *dev;
323 int ret;
324 u32 mux;
326 rproc = __pru_rproc_get(np, index);
327 if (IS_ERR(rproc))
328 return rproc;
330 pru = rproc->priv;
331 dev = &rproc->dev;
333 mutex_lock(&pru->lock);
335 if (pru->client_np) {
336 mutex_unlock(&pru->lock);
337 put_device(&rproc->dev);
338 return ERR_PTR(-EBUSY);
339 }
341 pru->client_np = np;
342 rproc->deny_sysfs_ops = 1;
344 mutex_unlock(&pru->lock);
346 ret = pruss_cfg_get_gpmux(pru->pruss, pru->id, &pru->gpmux_save);
347 if (ret) {
348 dev_err(dev, "failed to get cfg gpmux: %d\n", ret);
349 goto err;
350 }
352 ret = of_property_read_u32_index(np, "ti,pruss-gp-mux-sel", index,
353 &mux);
354 if (!ret) {
355 ret = pruss_cfg_set_gpmux(pru->pruss, pru->id, mux);
356 if (ret) {
357 dev_err(dev, "failed to set cfg gpmux: %d\n", ret);
358 goto err;
359 }
360 }
362 ret = of_property_read_string_index(np, "firmware-name", index,
363 &fw_name);
364 if (!ret) {
365 ret = pru_rproc_set_firmware(rproc, fw_name);
366 if (ret) {
367 dev_err(dev, "failed to set firmware: %d\n", ret);
368 goto err;
369 }
370 }
372 ret = pru_rproc_intc_dt_config(pru, index);
373 if (ret)
374 goto err;
376 return rproc;
378 err:
379 pru_rproc_put(rproc);
380 return ERR_PTR(ret);
381 }
382 EXPORT_SYMBOL_GPL(pru_rproc_get);
384 /**
385 * pru_rproc_put() - release the PRU rproc resource
386 * @rproc: the rproc resource to release
387 *
388 * Releases the PRU rproc resource and makes it available to other
389 * users.
390 */
391 void pru_rproc_put(struct rproc *rproc)
392 {
393 struct pru_rproc *pru;
395 if (IS_ERR_OR_NULL(rproc))
396 return;
398 /* TODO: replace the crude string based check to make sure it is PRU */
399 if (!strstr(dev_name(rproc->dev.parent), "pru") &&
400 !strstr(dev_name(rproc->dev.parent), "rtu"))
401 return;
403 pru = rproc->priv;
404 if (!pru->client_np)
405 return;
407 pruss_cfg_set_gpmux(pru->pruss, pru->id, pru->gpmux_save);
409 if (pru->dt_irqs)
410 pruss_intc_unconfigure(pru->pruss, &pru->intc_config);
412 pru_rproc_set_firmware(rproc, NULL);
414 mutex_lock(&pru->lock);
415 pru->client_np = NULL;
416 rproc->deny_sysfs_ops = 0;
417 mutex_unlock(&pru->lock);
419 put_device(&rproc->dev);
420 }
421 EXPORT_SYMBOL_GPL(pru_rproc_put);
423 /**
424 * pru_rproc_get_id() - get PRU id from a previously acquired PRU remoteproc
425 * @rproc: the rproc instance of the PRU
426 *
427 * Returns the PRU id of the PRU remote processor that has been acquired through
428 * a pru_rproc_get(), or a negative value on error
429 */
430 enum pruss_pru_id pru_rproc_get_id(struct rproc *rproc)
431 {
432 struct pru_rproc *pru;
434 if (IS_ERR_OR_NULL(rproc) || !rproc->dev.parent)
435 return -EINVAL;
437 /* TODO: replace the crude string based check to make sure it is PRU */
438 if (!strstr(dev_name(rproc->dev.parent), "pru") &&
439 !strstr(dev_name(rproc->dev.parent), "rtu"))
440 return -EINVAL;
442 pru = rproc->priv;
443 return pru->id;
444 }
445 EXPORT_SYMBOL_GPL(pru_rproc_get_id);
447 /**
448 * pru_rproc_set_ctable() - set the constant table index for the PRU
449 * @rproc: the rproc instance of the PRU
450 * @c: constant table index to set
451 * @addr: physical address to set it to
452 */
453 int pru_rproc_set_ctable(struct rproc *rproc, enum pru_ctable_idx c, u32 addr)
454 {
455 struct pru_rproc *pru = rproc->priv;
456 unsigned int reg;
457 u32 mask, set;
458 u16 idx;
459 u16 idx_mask;
461 /* pointer is 16 bit and index is 8-bit so mask out the rest */
462 idx_mask = (c >= PRU_C28) ? 0xFFFF : 0xFF;
464 /* ctable uses bit 8 and upwards only */
465 idx = (addr >> 8) & idx_mask;
467 /* configurable ctable (i.e. C24) starts at PRU_CTRL_CTBIR0 */
468 reg = PRU_CTRL_CTBIR0 + 4 * (c >> 1);
469 mask = idx_mask << (16 * (c & 1));
470 set = idx << (16 * (c & 1));
472 pru_control_set_reg(pru, reg, mask, set);
474 return 0;
475 }
476 EXPORT_SYMBOL_GPL(pru_rproc_set_ctable);
478 static inline u32 pru_debug_read_reg(struct pru_rproc *pru, unsigned int reg)
479 {
480 return readl_relaxed(pru->mem_regions[PRU_IOMEM_DEBUG].va + reg);
481 }
483 static inline
484 void pru_debug_write_reg(struct pru_rproc *pru, unsigned int reg, u32 val)
485 {
486 writel_relaxed(val, pru->mem_regions[PRU_IOMEM_DEBUG].va + reg);
487 }
489 static int regs_show(struct seq_file *s, void *data)
490 {
491 struct rproc *rproc = s->private;
492 struct pru_rproc *pru = rproc->priv;
493 int i, nregs = 32;
494 u32 pru_sts;
495 int pru_is_running;
497 seq_puts(s, "============== Control Registers ==============\n");
498 seq_printf(s, "CTRL := 0x%08x\n",
499 pru_control_read_reg(pru, PRU_CTRL_CTRL));
500 pru_sts = pru_control_read_reg(pru, PRU_CTRL_STS);
501 seq_printf(s, "STS (PC) := 0x%08x (0x%08x)\n", pru_sts, pru_sts << 2);
502 seq_printf(s, "WAKEUP_EN := 0x%08x\n",
503 pru_control_read_reg(pru, PRU_CTRL_WAKEUP_EN));
504 seq_printf(s, "CYCLE := 0x%08x\n",
505 pru_control_read_reg(pru, PRU_CTRL_CYCLE));
506 seq_printf(s, "STALL := 0x%08x\n",
507 pru_control_read_reg(pru, PRU_CTRL_STALL));
508 seq_printf(s, "CTBIR0 := 0x%08x\n",
509 pru_control_read_reg(pru, PRU_CTRL_CTBIR0));
510 seq_printf(s, "CTBIR1 := 0x%08x\n",
511 pru_control_read_reg(pru, PRU_CTRL_CTBIR1));
512 seq_printf(s, "CTPPR0 := 0x%08x\n",
513 pru_control_read_reg(pru, PRU_CTRL_CTPPR0));
514 seq_printf(s, "CTPPR1 := 0x%08x\n",
515 pru_control_read_reg(pru, PRU_CTRL_CTPPR1));
517 seq_puts(s, "=============== Debug Registers ===============\n");
518 pru_is_running = pru_control_read_reg(pru, PRU_CTRL_CTRL) &
519 CTRL_CTRL_RUNSTATE;
520 if (pru_is_running) {
521 seq_puts(s, "PRU is executing, cannot print/access debug registers.\n");
522 return 0;
523 }
525 for (i = 0; i < nregs; i++) {
526 seq_printf(s, "GPREG%-2d := 0x%08x\tCT_REG%-2d := 0x%08x\n",
527 i, pru_debug_read_reg(pru, PRU_DEBUG_GPREG(i)),
528 i, pru_debug_read_reg(pru, PRU_DEBUG_CT_REG(i)));
529 }
531 return 0;
532 }
534 DEFINE_SHOW_ATTRIBUTE(regs);
536 /*
537 * Control PRU single-step mode
538 *
539 * This is a debug helper function used for controlling the single-step
540 * mode of the PRU. The PRU Debug registers are not accessible when the
541 * PRU is in RUNNING state.
542 *
543 * Writing a non-zero value sets the PRU into single-step mode irrespective
544 * of its previous state. The PRU mode is saved only on the first set into
545 * a single-step mode. Writing a zero value will restore the PRU into its
546 * original mode.
547 */
548 static int pru_rproc_debug_ss_set(void *data, u64 val)
549 {
550 struct rproc *rproc = data;
551 struct pru_rproc *pru = rproc->priv;
552 u32 reg_val;
554 val = val ? 1 : 0;
555 if (!val && !pru->dbg_single_step)
556 return 0;
558 reg_val = pru_control_read_reg(pru, PRU_CTRL_CTRL);
560 if (val && !pru->dbg_single_step)
561 pru->dbg_continuous = reg_val;
563 if (val)
564 reg_val |= CTRL_CTRL_SINGLE_STEP | CTRL_CTRL_EN;
565 else
566 reg_val = pru->dbg_continuous;
568 pru->dbg_single_step = val;
569 pru_control_write_reg(pru, PRU_CTRL_CTRL, reg_val);
571 return 0;
572 }
574 static int pru_rproc_debug_ss_get(void *data, u64 *val)
575 {
576 struct rproc *rproc = data;
577 struct pru_rproc *pru = rproc->priv;
579 *val = pru->dbg_single_step;
581 return 0;
582 }
583 DEFINE_SIMPLE_ATTRIBUTE(pru_rproc_debug_ss_fops, pru_rproc_debug_ss_get,
584 pru_rproc_debug_ss_set, "%llu\n");
586 /*
587 * Create PRU-specific debugfs entries
588 *
589 * The entries are created only if the parent remoteproc debugfs directory
590 * exists, and will be cleaned up by the remoteproc core.
591 */
592 static void pru_rproc_create_debug_entries(struct rproc *rproc)
593 {
594 if (!rproc->dbg_dir)
595 return;
597 debugfs_create_file("regs", 0400, rproc->dbg_dir,
598 rproc, ®s_fops);
599 debugfs_create_file("single_step", 0600, rproc->dbg_dir,
600 rproc, &pru_rproc_debug_ss_fops);
601 }
603 /**
604 * pru_rproc_mbox_callback() - inbound mailbox message handler
605 * @client: mailbox client pointer used for requesting the mailbox channel
606 * @data: mailbox payload
607 *
608 * This handler is invoked by omap's mailbox driver whenever a mailbox
609 * message is received. Usually, the mailbox payload simply contains
610 * the index of the virtqueue that is kicked by the PRU remote processor,
611 * and we let remoteproc core handle it.
612 *
613 * In addition to virtqueue indices, we might also have some out-of-band
614 * values that indicates different events. Those values are deliberately
615 * very big so they don't coincide with virtqueue indices.
616 */
617 static void pru_rproc_mbox_callback(struct mbox_client *client, void *data)
618 {
619 struct pru_rproc *pru = container_of(client, struct pru_rproc, client);
620 struct device *dev = &pru->rproc->dev;
621 u32 msg = to_omap_mbox_msg(data);
623 dev_dbg(dev, "mbox msg: 0x%x\n", msg);
625 /* msg contains the index of the triggered vring */
626 if (rproc_vq_interrupt(pru->rproc, msg) == IRQ_NONE)
627 dev_dbg(dev, "no message was found in vqid %d\n", msg);
628 }
630 /**
631 * pru_rproc_vring_interrupt() - interrupt handler for processing vrings
632 * @irq: irq number associated with the PRU event MPU is listening on
633 * @data: interrupt handler data, will be a PRU rproc structure
634 *
635 * This handler is used by the PRU remoteproc driver when using PRU system
636 * events for processing the virtqueues. Unlike the mailbox IP, there is
637 * no payload associated with an interrupt, so either a unique event is
638 * used for each virtqueue kick, or a both virtqueues are processed on
639 * a single event. The latter is chosen to conserve the usable PRU system
640 * events.
641 */
642 static irqreturn_t pru_rproc_vring_interrupt(int irq, void *data)
643 {
644 struct pru_rproc *pru = data;
646 dev_dbg(&pru->rproc->dev, "got vring irq\n");
648 /* process incoming buffers on both the Rx and Tx vrings */
649 rproc_vq_interrupt(pru->rproc, 0);
650 rproc_vq_interrupt(pru->rproc, 1);
652 return IRQ_HANDLED;
653 }
655 /* kick a virtqueue */
656 static void pru_rproc_kick(struct rproc *rproc, int vq_id)
657 {
658 struct device *dev = &rproc->dev;
659 struct pru_rproc *pru = rproc->priv;
660 int ret;
661 mbox_msg_t msg = (mbox_msg_t)vq_id;
662 const char *name = pru->is_rtu ? "RTU" : "PRU";
664 dev_dbg(dev, "kicking vqid %d on %s%d\n", vq_id, name, pru->id);
666 if (pru->irq_kick > 0) {
667 ret = pruss_intc_trigger(pru->irq_kick);
668 if (ret < 0)
669 dev_err(dev, "pruss_intc_trigger failed: %d\n", ret);
670 } else if (pru->mbox) {
671 /*
672 * send the index of the triggered virtqueue in the mailbox
673 * payload
674 */
675 ret = mbox_send_message(pru->mbox, (void *)msg);
676 if (ret < 0)
677 dev_err(dev, "mbox_send_message failed: %d\n", ret);
678 }
679 }
681 /* start a PRU core */
682 static int pru_rproc_start(struct rproc *rproc)
683 {
684 struct device *dev = &rproc->dev;
685 struct pru_rproc *pru = rproc->priv;
686 const char *name = pru->is_rtu ? "RTU" : "PRU";
687 u32 val;
688 int ret;
690 dev_dbg(dev, "starting %s%d: entry-point = 0x%x\n",
691 name, pru->id, (rproc->bootaddr >> 2));
693 if (!list_empty(&pru->rproc->rvdevs)) {
694 if (!pru->mbox && (pru->irq_vring <= 0 || pru->irq_kick <= 0)) {
695 dev_err(dev, "virtio vring interrupt mechanisms are not provided\n");
696 ret = -EINVAL;
697 goto fail;
698 }
700 if (!pru->mbox && pru->irq_vring > 0) {
701 ret = request_threaded_irq(pru->irq_vring, NULL,
702 pru_rproc_vring_interrupt,
703 IRQF_ONESHOT, dev_name(dev),
704 pru);
705 if (ret) {
706 dev_err(dev, "failed to enable vring interrupt, ret = %d\n",
707 ret);
708 goto fail;
709 }
710 }
711 }
713 val = CTRL_CTRL_EN | ((rproc->bootaddr >> 2) << 16);
714 pru_control_write_reg(pru, PRU_CTRL_CTRL, val);
716 return 0;
718 fail:
719 if (!pru->dt_irqs && pru->fw_has_intc_rsc)
720 pruss_intc_unconfigure(pru->pruss, &pru->intc_config);
721 return ret;
722 }
724 /* stop/disable a PRU core */
725 static int pru_rproc_stop(struct rproc *rproc)
726 {
727 struct device *dev = &rproc->dev;
728 struct pru_rproc *pru = rproc->priv;
729 const char *name = pru->is_rtu ? "RTU" : "PRU";
730 u32 val;
732 dev_dbg(dev, "stopping %s%d\n", name, pru->id);
734 val = pru_control_read_reg(pru, PRU_CTRL_CTRL);
735 val &= ~CTRL_CTRL_EN;
736 pru_control_write_reg(pru, PRU_CTRL_CTRL, val);
738 if (!list_empty(&pru->rproc->rvdevs) &&
739 !pru->mbox && pru->irq_vring > 0)
740 free_irq(pru->irq_vring, pru);
742 /* undo INTC config */
743 if (!pru->dt_irqs && pru->fw_has_intc_rsc)
744 pruss_intc_unconfigure(pru->pruss, &pru->intc_config);
746 return 0;
747 }
749 /*
750 * parse the custom PRU interrupt map resource and configure the INTC
751 * appropriately
752 */
753 static int pru_handle_vendor_intrmap(struct rproc *rproc,
754 struct fw_rsc_vendor *rsc)
755 {
756 struct device *dev = rproc->dev.parent;
757 struct pru_rproc *pru = rproc->priv;
758 struct pruss *pruss = pru->pruss;
759 struct pruss_event_chnl *event_chnl_map;
760 struct fw_rsc_pruss_intrmap *intr_rsc0;
761 struct fw_rsc_pruss_intrmap_k3 *intr_rsc1;
762 int i, ret;
763 u32 event_chnl_map_da, event_chnl_map_size;
764 s8 sys_evt, chnl, intr_no;
765 s8 *chnl_host_intr_map;
766 u8 max_system_events, max_pru_channels, max_pru_host_ints;
768 if (rsc->u.st.st_ver != 0 && rsc->u.st.st_ver != 1) {
769 dev_err(dev, "only PRU interrupt resource versions 0 and 1 are supported\n");
770 return -EINVAL;
771 }
773 if (!rsc->u.st.st_ver) {
774 intr_rsc0 = (struct fw_rsc_pruss_intrmap *)rsc->data;
775 event_chnl_map_da = intr_rsc0->event_chnl_map_addr;
776 event_chnl_map_size = intr_rsc0->event_chnl_map_size;
777 chnl_host_intr_map = intr_rsc0->chnl_host_intr_map;
778 max_system_events = MAX_PRU_SYS_EVENTS;
779 max_pru_channels = MAX_PRU_CHANNELS;
780 max_pru_host_ints = MAX_PRU_HOST_INT;
782 dev_dbg(dev, "version %d event_chnl_map_size %d event_chnl_map_da 0x%x\n",
783 rsc->u.st.st_ver, intr_rsc0->event_chnl_map_size,
784 event_chnl_map_da);
785 } else {
786 intr_rsc1 = (struct fw_rsc_pruss_intrmap_k3 *)rsc->data;
787 event_chnl_map_da = intr_rsc1->event_chnl_map_addr;
788 event_chnl_map_size = intr_rsc1->event_chnl_map_size;
789 chnl_host_intr_map = intr_rsc1->chnl_host_intr_map;
790 max_system_events = MAX_PRU_SYS_EVENTS_K3;
791 max_pru_channels = MAX_PRU_CHANNELS_K3;
792 max_pru_host_ints = MAX_PRU_HOST_INT_K3;
794 dev_dbg(dev, "version %d event_chnl_map_size %d event_chnl_map_da 0x%x\n",
795 rsc->u.st.st_ver, intr_rsc1->event_chnl_map_size,
796 event_chnl_map_da);
797 }
799 if (event_chnl_map_size < 0 ||
800 event_chnl_map_size >= max_system_events) {
801 dev_err(dev, "PRU interrupt resource has more events than present on hardware\n");
802 return -EINVAL;
803 }
805 /*
806 * XXX: The event_chnl_map_addr mapping is currently a pointer in device
807 * memory, evaluate if this needs to be directly in firmware file.
808 */
809 event_chnl_map = pru_d_da_to_va(pru, event_chnl_map_da,
810 event_chnl_map_size *
811 sizeof(*event_chnl_map));
812 if (!event_chnl_map) {
813 dev_err(dev, "PRU interrupt resource has inadequate event_chnl_map configuration\n");
814 return -EINVAL;
815 }
817 /* init intc_config to defaults */
818 for (i = 0; i < ARRAY_SIZE(pru->intc_config.sysev_to_ch); i++)
819 pru->intc_config.sysev_to_ch[i] = -1;
821 for (i = 0; i < ARRAY_SIZE(pru->intc_config.ch_to_host); i++)
822 pru->intc_config.ch_to_host[i] = -1;
824 /* parse and fill in system event to interrupt channel mapping */
825 for (i = 0; i < event_chnl_map_size; i++) {
826 sys_evt = event_chnl_map[i].event;
827 chnl = event_chnl_map[i].chnl;
829 if (sys_evt < 0 || sys_evt >= max_system_events) {
830 dev_err(dev, "[%d] bad sys event %d\n", i, sys_evt);
831 return -EINVAL;
832 }
833 if (chnl < 0 || chnl >= max_pru_channels) {
834 dev_err(dev, "[%d] bad channel value %d\n", i, chnl);
835 return -EINVAL;
836 }
838 pru->intc_config.sysev_to_ch[sys_evt] = chnl;
839 dev_dbg(dev, "sysevt-to-ch[%d] -> %d\n", sys_evt, chnl);
840 }
842 /* parse and handle interrupt channel-to-host interrupt mapping */
843 for (i = 0; i < max_pru_channels; i++) {
844 intr_no = chnl_host_intr_map[i];
845 if (intr_no < 0) {
846 dev_dbg(dev, "skip intr mapping for chnl %d\n", i);
847 continue;
848 }
850 if (intr_no >= max_pru_host_ints) {
851 dev_err(dev, "bad intr mapping for chnl %d, intr_no %d\n",
852 i, intr_no);
853 return -EINVAL;
854 }
856 pru->intc_config.ch_to_host[i] = intr_no;
857 dev_dbg(dev, "chnl-to-host[%d] -> %d\n", i, intr_no);
858 }
860 pru->fw_has_intc_rsc = 1;
862 ret = pruss_intc_configure(pruss, &pru->intc_config);
863 if (ret)
864 dev_err(dev, "failed to configure pruss intc %d\n", ret);
866 return ret;
867 }
869 /* PRU-specific vendor resource handler */
870 static int pru_rproc_handle_vendor_rsc(struct rproc *rproc,
871 struct fw_rsc_vendor *rsc)
872 {
873 struct device *dev = rproc->dev.parent;
874 struct pru_rproc *pru = rproc->priv;
875 int ret = 0;
877 switch (rsc->u.st.st_type) {
878 case PRUSS_RSC_INTRS:
879 if (!pru->dt_irqs)
880 ret = pru_handle_vendor_intrmap(rproc, rsc);
881 break;
882 default:
883 dev_err(dev, "%s: cannot handle unknown type %d\n", __func__,
884 rsc->u.st.st_type);
885 ret = -EINVAL;
886 }
888 return ret;
889 }
891 /*
892 * Convert PRU device address (data spaces only) to kernel virtual address
893 *
894 * Each PRU has access to all data memories within the PRUSS, accessible at
895 * different ranges. So, look through both its primary and secondary Data
896 * RAMs as well as any shared Data RAM to convert a PRU device address to
897 * kernel virtual address. Data RAM0 is primary Data RAM for PRU0 and Data
898 * RAM1 is primary Data RAM for PRU1.
899 */
900 static void *pru_d_da_to_va(struct pru_rproc *pru, u32 da, int len)
901 {
902 struct pruss_mem_region dram0, dram1, shrd_ram;
903 struct pruss *pruss = pru->pruss;
904 u32 offset;
905 void *va = NULL;
907 if (len <= 0)
908 return NULL;
910 dram0 = pruss->mem_regions[PRUSS_MEM_DRAM0];
911 dram1 = pruss->mem_regions[PRUSS_MEM_DRAM1];
912 /* PRU1 has its local RAM addresses reversed */
913 if (pru->id == 1)
914 swap(dram0, dram1);
915 shrd_ram = pruss->mem_regions[PRUSS_MEM_SHRD_RAM2];
917 if (da >= pru->pdram_da && da + len <= pru->pdram_da + dram0.size) {
918 offset = da - pru->pdram_da;
919 va = (__force void *)(dram0.va + offset);
920 } else if (da >= pru->sdram_da &&
921 da + len <= pru->sdram_da + dram1.size) {
922 offset = da - pru->sdram_da;
923 va = (__force void *)(dram1.va + offset);
924 } else if (da >= pru->shrdram_da &&
925 da + len <= pru->shrdram_da + shrd_ram.size) {
926 offset = da - pru->shrdram_da;
927 va = (__force void *)(shrd_ram.va + offset);
928 }
930 return va;
931 }
933 /*
934 * Convert PRU device address (instruction space) to kernel virtual address
935 *
936 * A PRU does not have an unified address space. Each PRU has its very own
937 * private Instruction RAM, and its device address is identical to that of
938 * its primary Data RAM device address.
939 */
940 static void *pru_i_da_to_va(struct pru_rproc *pru, u32 da, int len)
941 {
942 u32 offset;
943 void *va = NULL;
945 if (len <= 0)
946 return NULL;
948 if (da >= pru->iram_da &&
949 da + len <= pru->iram_da + pru->mem_regions[PRU_IOMEM_IRAM].size) {
950 offset = da - pru->iram_da;
951 va = (__force void *)(pru->mem_regions[PRU_IOMEM_IRAM].va +
952 offset);
953 }
955 return va;
956 }
958 /* PRU-specific address translator */
959 static void *pru_da_to_va(struct rproc *rproc, u64 da, int len, u32 flags)
960 {
961 struct pru_rproc *pru = rproc->priv;
962 void *va;
963 u32 exec_flag;
965 exec_flag = ((flags & RPROC_FLAGS_ELF_SHDR) ? flags & SHF_EXECINSTR :
966 ((flags & RPROC_FLAGS_ELF_PHDR) ? flags & PF_X : 0));
968 if (exec_flag)
969 va = pru_i_da_to_va(pru, da, len);
970 else
971 va = pru_d_da_to_va(pru, da, len);
973 return va;
974 }
976 static struct rproc_ops pru_rproc_ops = {
977 .start = pru_rproc_start,
978 .stop = pru_rproc_stop,
979 .kick = pru_rproc_kick,
980 .handle_vendor_rsc = pru_rproc_handle_vendor_rsc,
981 .da_to_va = pru_da_to_va,
982 };
984 /*
985 * Custom memory copy implementation for ICSSG PRU/RTU Cores
986 *
987 * The ICSSG PRU/RTU cores have a memory copying issue with IRAM memories, that
988 * is not seen on previous generation SoCs. The data is reflected properly in
989 * the IRAM memories only for integer (4-byte) copies. Any unaligned copies
990 * result in all the other pre-existing bytes zeroed out within that 4-byte
991 * boundary, thereby resulting in wrong text/code in the IRAMs. Also, the
992 * IRAM memory port interface does not allow any 8-byte copies (as commonly
993 * used by ARM64 memcpy implementation) and throws an exception. The DRAM
994 * memory ports do not show this behavior. Use this custom copying function
995 * to properly load the PRU/RTU firmware images on all memories for simplicity.
996 *
997 * TODO: Improve the function to deal with additional corner cases like
998 * unaligned copy sizes or sub-integer trailing bytes when the need arises.
999 */
1000 static int pru_rproc_memcpy(void *dest, const void *src, size_t count)
1001 {
1002 const int *s = src;
1003 int *d = dest;
1004 int size = count / 4;
1005 int *tmp_src = NULL;
1007 /* limited to 4-byte aligned addresses and copy sizes */
1008 if ((long)dest % 4 || count % 4)
1009 return -EINVAL;
1011 /* src offsets in ELF firmware image can be non-aligned */
1012 if ((long)src % 4) {
1013 tmp_src = kmemdup(src, count, GFP_KERNEL);
1014 if (!tmp_src)
1015 return -ENOMEM;
1016 s = tmp_src;
1017 }
1019 while (size--)
1020 *d++ = *s++;
1022 kfree(tmp_src);
1024 return 0;
1025 }
1027 static int
1028 pru_rproc_load_elf_segments(struct rproc *rproc, const struct firmware *fw)
1029 {
1030 struct device *dev = &rproc->dev;
1031 struct elf32_hdr *ehdr;
1032 struct elf32_phdr *phdr;
1033 int i, ret = 0;
1034 const u8 *elf_data = fw->data;
1036 ehdr = (struct elf32_hdr *)elf_data;
1037 phdr = (struct elf32_phdr *)(elf_data + ehdr->e_phoff);
1039 /* go through the available ELF segments */
1040 for (i = 0; i < ehdr->e_phnum; i++, phdr++) {
1041 u32 da = phdr->p_paddr;
1042 u32 memsz = phdr->p_memsz;
1043 u32 filesz = phdr->p_filesz;
1044 u32 offset = phdr->p_offset;
1045 void *ptr;
1047 if (phdr->p_type != PT_LOAD)
1048 continue;
1050 dev_dbg(dev, "phdr: type %d da 0x%x memsz 0x%x filesz 0x%x\n",
1051 phdr->p_type, da, memsz, filesz);
1053 if (filesz > memsz) {
1054 dev_err(dev, "bad phdr filesz 0x%x memsz 0x%x\n",
1055 filesz, memsz);
1056 ret = -EINVAL;
1057 break;
1058 }
1060 if (offset + filesz > fw->size) {
1061 dev_err(dev, "truncated fw: need 0x%x avail 0x%zx\n",
1062 offset + filesz, fw->size);
1063 ret = -EINVAL;
1064 break;
1065 }
1067 /* grab the kernel address for this device address */
1068 ptr = rproc_da_to_va(rproc, da, memsz,
1069 RPROC_FLAGS_ELF_PHDR | phdr->p_flags);
1070 if (!ptr) {
1071 dev_err(dev, "bad phdr da 0x%x mem 0x%x\n", da, memsz);
1072 ret = -EINVAL;
1073 break;
1074 }
1076 /* skip the memzero logic performed by remoteproc ELF loader */
1077 if (!phdr->p_filesz)
1078 continue;
1080 ret = pru_rproc_memcpy(ptr, elf_data + phdr->p_offset, filesz);
1081 if (ret) {
1082 dev_err(dev, "PRU custom memory copy failed for da 0x%x memsz 0x%x\n",
1083 da, memsz);
1084 break;
1085 }
1086 }
1088 return ret;
1089 }
1091 /*
1092 * compute PRU id based on the IRAM addresses. The PRU IRAMs are
1093 * always at a particular offset within the PRUSS address space.
1094 * The other alternative is to use static data for each core (not a
1095 * hardware property to define it in DT), and the id can always be
1096 * computated using this inherent address logic.
1097 */
1098 static int pru_rproc_set_id(struct device_node *np, struct pru_rproc *pru)
1099 {
1100 int ret = 0;
1101 u32 mask1 = PRU0_IRAM_ADDR_MASK;
1102 u32 mask2 = PRU1_IRAM_ADDR_MASK;
1104 if (of_device_is_compatible(np, "ti,am654-rtu")) {
1105 mask1 = RTU0_IRAM_ADDR_MASK;
1106 mask2 = RTU1_IRAM_ADDR_MASK;
1107 pru->is_rtu = 1;
1108 }
1110 if ((pru->mem_regions[PRU_IOMEM_IRAM].pa & mask2) == mask2)
1111 pru->id = PRUSS_PRU1;
1112 else if ((pru->mem_regions[PRU_IOMEM_IRAM].pa & mask1) == mask1)
1113 pru->id = PRUSS_PRU0;
1114 else
1115 ret = -EINVAL;
1117 return ret;
1118 }
1120 static int pru_rproc_probe(struct platform_device *pdev)
1121 {
1122 struct device *dev = &pdev->dev;
1123 struct device_node *np = dev->of_node;
1124 struct platform_device *ppdev = to_platform_device(dev->parent);
1125 struct pru_rproc *pru;
1126 const char *fw_name;
1127 struct rproc *rproc = NULL;
1128 struct mbox_client *client;
1129 struct resource *res;
1130 int i, ret;
1131 const char *mem_names[PRU_IOMEM_MAX] = { "iram", "control", "debug" };
1133 if (!np) {
1134 dev_err(dev, "Non-DT platform device not supported\n");
1135 return -ENODEV;
1136 }
1138 ret = of_property_read_string(np, "firmware-name", &fw_name);
1139 if (ret) {
1140 dev_err(dev, "unable to retrieve firmware-name %d\n", ret);
1141 return ret;
1142 }
1144 rproc = rproc_alloc(dev, pdev->name, &pru_rproc_ops, fw_name,
1145 sizeof(*pru));
1146 if (!rproc) {
1147 dev_err(dev, "rproc_alloc failed\n");
1148 return -ENOMEM;
1149 }
1150 /* error recovery is not supported for PRUs */
1151 rproc->recovery_disabled = true;
1153 /*
1154 * rproc_add will auto-boot the processor normally, but this is
1155 * not desired with PRU client driven boot-flow methodology. A PRU
1156 * application/client driver will boot the corresponding PRU
1157 * remote-processor as part of its state machine either through
1158 * the remoteproc sysfs interface or through the equivalent kernel API
1159 */
1160 rproc->auto_boot = false;
1162 pru = rproc->priv;
1163 pru->pruss = platform_get_drvdata(ppdev);
1164 pru->rproc = rproc;
1165 pru->fw_name = fw_name;
1166 spin_lock_init(&pru->rmw_lock);
1167 mutex_init(&pru->lock);
1169 if (of_device_is_compatible(np, "ti,am654-pru") ||
1170 of_device_is_compatible(np, "ti,am654-rtu")) {
1171 /* use generic elf ops for undefined platform driver ops */
1172 rproc->ops->load = pru_rproc_load_elf_segments;
1174 pru->is_k3 = 1;
1175 }
1177 /* XXX: get this from match data if different in the future */
1178 pru->iram_da = 0;
1179 pru->pdram_da = 0;
1180 pru->sdram_da = 0x2000;
1181 pru->shrdram_da = 0x10000;
1183 for (i = 0; i < ARRAY_SIZE(mem_names); i++) {
1184 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
1185 mem_names[i]);
1186 pru->mem_regions[i].va = devm_ioremap_resource(dev, res);
1187 if (IS_ERR(pru->mem_regions[i].va)) {
1188 dev_err(dev, "failed to parse and map memory resource %d %s\n",
1189 i, mem_names[i]);
1190 ret = PTR_ERR(pru->mem_regions[i].va);
1191 goto free_rproc;
1192 }
1193 pru->mem_regions[i].pa = res->start;
1194 pru->mem_regions[i].size = resource_size(res);
1196 dev_dbg(dev, "memory %8s: pa %pa size 0x%zx va %p\n",
1197 mem_names[i], &pru->mem_regions[i].pa,
1198 pru->mem_regions[i].size, pru->mem_regions[i].va);
1199 }
1201 ret = pru_rproc_set_id(np, pru);
1202 if (ret < 0)
1203 goto free_rproc;
1205 platform_set_drvdata(pdev, rproc);
1207 /* get optional vring and kick interrupts for supporting virtio rpmsg */
1208 pru->irq_vring = platform_get_irq_byname(pdev, "vring");
1209 if (pru->irq_vring <= 0) {
1210 ret = pru->irq_vring;
1211 if (ret == -EPROBE_DEFER)
1212 goto free_rproc;
1213 dev_dbg(dev, "unable to get vring interrupt, status = %d\n",
1214 ret);
1215 }
1217 pru->irq_kick = platform_get_irq_byname(pdev, "kick");
1218 if (pru->irq_kick <= 0) {
1219 ret = pru->irq_kick;
1220 if (ret == -EPROBE_DEFER)
1221 goto free_rproc;
1222 dev_dbg(dev, "unable to get kick interrupt, status = %d\n",
1223 ret);
1224 }
1226 /*
1227 * get optional mailbox for virtio rpmsg signalling if vring and kick
1228 * interrupts are not specified for OMAP architecture based SoCs
1229 */
1230 if (pru->irq_vring <= 0 && pru->irq_kick <= 0 &&
1231 !of_device_is_compatible(np, "ti,k2g-pru")) {
1232 client = &pru->client;
1233 client->dev = dev;
1234 client->tx_done = NULL;
1235 client->rx_callback = pru_rproc_mbox_callback;
1236 client->tx_block = false;
1237 client->knows_txdone = false;
1238 pru->mbox = mbox_request_channel(client, 0);
1239 if (IS_ERR(pru->mbox)) {
1240 ret = PTR_ERR(pru->mbox);
1241 pru->mbox = NULL;
1242 dev_dbg(dev, "unable to get mailbox channel, status = %d\n",
1243 ret);
1244 }
1245 }
1247 ret = rproc_add(pru->rproc);
1248 if (ret) {
1249 dev_err(dev, "rproc_add failed: %d\n", ret);
1250 goto put_mbox;
1251 }
1253 pru_rproc_create_debug_entries(rproc);
1255 dev_info(dev, "PRU rproc node %s probed successfully\n", np->full_name);
1257 return 0;
1259 put_mbox:
1260 mbox_free_channel(pru->mbox);
1261 free_rproc:
1262 rproc_free(rproc);
1263 return ret;
1264 }
1266 static int pru_rproc_remove(struct platform_device *pdev)
1267 {
1268 struct device *dev = &pdev->dev;
1269 struct rproc *rproc = platform_get_drvdata(pdev);
1270 struct pru_rproc *pru = rproc->priv;
1272 dev_info(dev, "%s: removing rproc %s\n", __func__, rproc->name);
1274 mbox_free_channel(pru->mbox);
1276 rproc_del(rproc);
1277 rproc_free(rproc);
1279 return 0;
1280 }
1282 static const struct of_device_id pru_rproc_match[] = {
1283 { .compatible = "ti,am3356-pru", },
1284 { .compatible = "ti,am4376-pru", },
1285 { .compatible = "ti,am5728-pru", },
1286 { .compatible = "ti,k2g-pru", },
1287 { .compatible = "ti,am654-pru", },
1288 { .compatible = "ti,am654-rtu", },
1289 {},
1290 };
1291 MODULE_DEVICE_TABLE(of, pru_rproc_match);
1293 static struct platform_driver pru_rproc_driver = {
1294 .driver = {
1295 .name = "pru-rproc",
1296 .of_match_table = pru_rproc_match,
1297 .suppress_bind_attrs = true,
1298 },
1299 .probe = pru_rproc_probe,
1300 .remove = pru_rproc_remove,
1301 };
1302 module_platform_driver(pru_rproc_driver);
1304 MODULE_AUTHOR("Suman Anna <s-anna@ti.com>");
1305 MODULE_DESCRIPTION("PRU-ICSS Remote Processor Driver");
1306 MODULE_LICENSE("GPL v2");