Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 26 additions & 22 deletions patches/capes/0021-remoteproc-PRU-lighting-remoteproc-support.patch
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
From 2ad8aa0e62a81190557cf1788991b4adda61ac9d Mon Sep 17 00:00:00 2001
From fef63a2a8a4afb3959c395b85f6f56d0ab4f937e Mon Sep 17 00:00:00 2001
From: Matt Ranostay <mranostay@gmail.com>
Date: Sun, 15 Dec 2013 00:44:34 -0800
Subject: [PATCH 21/22] remoteproc: PRU lighting remoteproc support
Date: Sat, 7 Dec 2013 13:29:43 -0800
Subject: [PATCH 2/2] remoteproc: PRU lighting remoteproc support

Multiple downcalls, ioctls, and spidev support to allow driving
of WS281x LEDS via remoteproc PRU firmware.

Signed-off-by: Matt Ranostay <mranostay@gmail.com>
---
drivers/remoteproc/pru_rproc.c | 279 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 273 insertions(+), 6 deletions(-)
drivers/remoteproc/pru_rproc.c | 283 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 277 insertions(+), 6 deletions(-)

diff --git a/drivers/remoteproc/pru_rproc.c b/drivers/remoteproc/pru_rproc.c
index 6e42db6..dcb24ee 100644
index 6e42db6..36d2ad5 100644
--- a/drivers/remoteproc/pru_rproc.c
+++ b/drivers/remoteproc/pru_rproc.c
@@ -28,9 +28,13 @@
Expand All @@ -29,7 +29,7 @@ index 6e42db6..dcb24ee 100644

#include "remoteproc_internal.h"

@@ -87,6 +91,34 @@ struct pruproc_core;
@@ -87,6 +91,35 @@ struct pruproc_core;
/* maximum PWMs */
#define PRU_PWM_MAX 32

Expand All @@ -42,9 +42,10 @@ index 6e42db6..dcb24ee 100644
+
+#define LED_DATA_PRU 0
+#define LED_DATA_OFFSET 0x1000
+#define LED_CONF_OFFSET 0x0800
+#define MAX_BUFFER (12*1024)
+#define MAX_SLOTS 170
+#define MAX_UNIVERSES 14
+#define MAX_SLOTS 256
+#define MAX_UNIVERSES 12
+
+struct pru_led_array {
+ __u8 universe;
Expand All @@ -64,15 +65,15 @@ index 6e42db6..dcb24ee 100644
struct pru_vring_info {
struct fw_rsc_vdev_vring *rsc;
struct vring vr;
@@ -138,6 +170,7 @@ struct pruproc_core {
@@ -138,6 +171,7 @@ struct pruproc_core {

/* downcall lock */
struct mutex dc_lock;
+ struct mutex io_lock;
wait_queue_head_t dc_waitq;
unsigned long dc_flags;
#define PRU_DCF_DOWNCALL_REQ 0
@@ -189,6 +222,11 @@ struct pruproc {
@@ -189,6 +223,11 @@ struct pruproc {
int controller;
u32 dc_ids[DC_PWM_MAX];
} pwm;
Expand All @@ -84,25 +85,25 @@ index 6e42db6..dcb24ee 100644
};

/* global memory map (for am33xx) (almost the same as local) */
@@ -1337,6 +1375,7 @@ static int pruproc_remove(struct platform_device *pdev)
@@ -1337,6 +1376,7 @@ static int pruproc_remove(struct platform_device *pdev)

device_remove_file(dev, &dev_attr_reset);
device_remove_file(dev, &dev_attr_load);
+ kfree(pp->led.buffer);

/* Unregister as remoteproc device */
for (i = pp->num_prus - 1; i >= 0; i--) {
@@ -1641,7 +1680,8 @@ static int pru_downcall(struct pruproc_core *ppc,
@@ -1641,7 +1681,8 @@ static int pru_downcall(struct pruproc_core *ppc,
ret = (int)intr;
dev_err(dev, "PRU#%d error waiting for downcall ready (%d)\n",
ppc->idx, ret);
- goto ret_call_failed;
+ if (pp_led)
+ if (pp_led == NULL)
+ goto ret_call_failed;
}
if (intr == 0) {
dev_err(dev, "PRU#%d failed to issue downcall ready in 100ms\n",
@@ -1683,7 +1723,8 @@ static int pru_downcall(struct pruproc_core *ppc,
@@ -1683,7 +1724,8 @@ static int pru_downcall(struct pruproc_core *ppc,
ret = (int)intr;
dev_err(dev, "PRU#%d error waiting for downcall done (%d)\n",
ppc->idx, ret);
Expand All @@ -112,7 +113,7 @@ index 6e42db6..dcb24ee 100644
}
if (intr == 0) {
dev_err(dev, "PRU#%d failed to issue downcall done in 100ms\n",
@@ -2334,16 +2375,242 @@ static int pruproc_create_pwm_devices(struct pruproc *pp)
@@ -2334,16 +2376,245 @@ static int pruproc_create_pwm_devices(struct pruproc *pp)
return 0;
}

Expand Down Expand Up @@ -164,7 +165,7 @@ index 6e42db6..dcb24ee 100644
+static long get_max_slots(struct pruproc *pp)
+{
+ void __iomem *va;
+ va = pru_d_da_to_va(pp->pru_to_pruc[LED_DATA_PRU], LED_DATA_OFFSET, NULL);
+ va = pru_d_da_to_va(pp->pru_to_pruc[LED_DATA_PRU], LED_CONF_OFFSET, NULL);
+
+ return *((u32 *)va) & 0xff;
+}
Expand Down Expand Up @@ -192,10 +193,13 @@ index 6e42db6..dcb24ee 100644
+ val |= *(d++) << 16;
+
+ array->data[slot] = val;
+ if (++slot > (max_slots - 1)) {
+ if (++slot > max_slots) {
+ slot = 0;
+ array->universe = uni++;
+
+ if (array->universe >= MAX_UNIVERSES)
+ break;
+
+ ioctl_write_burst(pp, array);
+ memset(array->data, 0, MAX_SLOTS * 4);
+ }
Expand Down Expand Up @@ -274,8 +278,7 @@ index 6e42db6..dcb24ee 100644
+ n_ioc = tmp / sizeof(struct spi_ioc_transfer);
+ if (n_ioc == 0)
+ break;

- ret = pruproc_create_pwm_devices(pp);
+
+ /* copy into scratch area */
+ ioc = kmalloc(tmp, GFP_KERNEL);
+ if (!ioc) {
Expand All @@ -289,7 +292,8 @@ index 6e42db6..dcb24ee 100644
+ }
+
+ ret = ioctl_spiwrite_burst(pp, ioc);
+

- ret = pruproc_create_pwm_devices(pp);
+ kfree(ioc);
+ }
+ mutex_unlock(&ppc->io_lock);
Expand Down Expand Up @@ -360,5 +364,5 @@ index 6e42db6..dcb24ee 100644
{
struct device *dev = &pdev->dev;
--
1.8.4.2
1.8.1.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
From b3644d057fd53e7142034b874ba68c087d3dcc28 Mon Sep 17 00:00:00 2001
From: Matt Ranostay <mranostay@gmail.com>
Date: Sat, 21 Dec 2013 22:27:48 -0800
Subject: [PATCH] capes: reorder from GRB to RGB for Lighting cape

Signed-off-by: Matt Ranostay <mranostay@gmail.com>
---
drivers/remoteproc/pru_rproc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/remoteproc/pru_rproc.c b/drivers/remoteproc/pru_rproc.c
index 36d2ad5..0f58370 100644
--- a/drivers/remoteproc/pru_rproc.c
+++ b/drivers/remoteproc/pru_rproc.c
@@ -2444,9 +2444,9 @@ static long ioctl_spiwrite_burst(struct pruproc *pp, struct spi_ioc_transfer *sp
memset(array->data, 0, MAX_SLOTS * 4);

for (i = 0; i < (spi->len / 3); i++) {
- u32 val = *(d++) << 0;
- val |= *(d++) << 8;
- val |= *(d++) << 16;
+ u32 val = *(d++) << 8; /* Red */
+ val |= *(d++) << 0; /* Green */
+ val |= *(d++) << 16; /* Blue */

array->data[slot] = val;
if (++slot > max_slots) {
--
1.8.1.2