Skip to content

Commit 66840ef

Browse files
notropopcornmix
authored andcommitted
rpi-ft5406: Use firmware API
Signed-off-by: Noralf Trønnes <[email protected]>
1 parent 8af1742 commit 66840ef

File tree

2 files changed

+32
-43
lines changed

2 files changed

+32
-43
lines changed

arch/arm/boot/dts/overlays/rpi-ft5406-overlay.dts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
__overlay__ {
1010
rpi_ft5406: rpi_ft5406 {
1111
compatible = "rpi,rpi-ft5406";
12+
firmware = <&firmware>;
1213
status = "okay";
1314
};
1415
};

drivers/input/touchscreen/rpi-ft5406.c

Lines changed: 31 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include <linux/kthread.h>
2222
#include <linux/platform_device.h>
2323
#include <asm/io.h>
24-
#include <linux/platform_data/mailbox-bcm2708.h>
24+
#include <soc/bcm2835/raspberrypi-firmware.h>
2525

2626
#define MAXIMUM_SUPPORTED_POINTS 10
2727
struct ft5406_regs {
@@ -49,23 +49,6 @@ struct ft5406 {
4949
struct task_struct * thread;
5050
};
5151

52-
53-
/* tag part of the message */
54-
struct vc_msg_tag {
55-
uint32_t tag_id; /* the message id */
56-
uint32_t buffer_size; /* size of the buffer (which in this case is always 8 bytes) */
57-
uint32_t data_size; /* amount of data being sent or received */
58-
uint32_t val; /* data buffer */
59-
};
60-
61-
/* message structure to be sent to videocore */
62-
struct vc_msg {
63-
uint32_t msg_size; /* simply, sizeof(struct vc_msg) */
64-
uint32_t request_code; /* holds various information like the success and number of bytes returned (refer to mailboxes wiki) */
65-
struct vc_msg_tag tag; /* the tag structure above to make */
66-
uint32_t end_tag; /* an end identifier, should be set to NULL */
67-
};
68-
6952
/* Thread to poll for touchscreen events
7053
*
7154
* This thread polls the memory based register copy of the ft5406 registers
@@ -136,11 +119,37 @@ static int ft5406_probe(struct platform_device *pdev)
136119
{
137120
int ret;
138121
struct input_dev * input_dev = input_allocate_device();
139-
struct vc_msg request;
140122
struct ft5406 * ts;
123+
struct device_node *fw_node;
124+
struct rpi_firmware *fw;
125+
u32 touchbuf;
141126

142127
dev_info(&pdev->dev, "Probing device\n");
143128

129+
fw_node = of_parse_phandle(pdev->dev.of_node, "firmware", 0);
130+
if (!fw_node) {
131+
dev_err(&pdev->dev, "Missing firmware node\n");
132+
return -ENOENT;
133+
}
134+
135+
fw = rpi_firmware_get(fw_node);
136+
if (!fw)
137+
return -EPROBE_DEFER;
138+
139+
ret = rpi_firmware_property(fw, RPI_FIRMWARE_FRAMEBUFFER_GET_TOUCHBUF,
140+
&touchbuf, sizeof(touchbuf));
141+
if (ret) {
142+
dev_err(&pdev->dev, "Failed to get touch buffer\n");
143+
return ret;
144+
}
145+
146+
if (!touchbuf) {
147+
dev_err(&pdev->dev, "Touchscreen not detected\n");
148+
return -ENODEV;
149+
}
150+
151+
dev_dbg(&pdev->dev, "Got TS buffer 0x%x\n", touchbuf);
152+
144153
ts = kzalloc(sizeof(struct ft5406), GFP_KERNEL);
145154

146155
if (!ts || !input_dev) {
@@ -174,36 +183,15 @@ static int ft5406_probe(struct platform_device *pdev)
174183
return ret;
175184
}
176185

177-
memset(&request, 0, sizeof request);
178-
179-
request.msg_size = sizeof request;
180-
request.request_code = VCMSG_PROCESS_REQUEST;
181-
request.tag.tag_id = VCMSG_GET_TOUCHBUF;
182-
request.tag.buffer_size = 4;
183-
request.tag.data_size = 4;
184-
185-
bcm_mailbox_property(&request, sizeof(request));
186-
187-
if(request.request_code == VCMSG_REQUEST_SUCCESSFUL && request.tag.val != 0)
188-
{
189-
dev_dbg(&pdev->dev, "Got TS buffer 0x%x\n", request.tag.val);
190-
}
191-
else
192-
{
193-
input_unregister_device(input_dev);
194-
kzfree(ts);
195-
return -1;
196-
}
197-
198186
// mmap the physical memory
199-
request.tag.val &= ~0xc0000000;
200-
ts->ts_base = ioremap(request.tag.val, sizeof(*ts->regs));
187+
touchbuf &= ~0xc0000000;
188+
ts->ts_base = ioremap(touchbuf, sizeof(*ts->regs));
201189
if(ts->ts_base == NULL)
202190
{
203191
dev_err(&pdev->dev, "Failed to map physical address\n");
204192
input_unregister_device(input_dev);
205193
kzfree(ts);
206-
return -1;
194+
return -ENOMEM;
207195
}
208196

209197
ts->regs = (struct ft5406_regs *) ts->ts_base;

0 commit comments

Comments
 (0)