|
21 | 21 | #include <linux/kthread.h>
|
22 | 22 | #include <linux/platform_device.h>
|
23 | 23 | #include <asm/io.h>
|
24 |
| -#include <linux/platform_data/mailbox-bcm2708.h> |
| 24 | +#include <soc/bcm2835/raspberrypi-firmware.h> |
25 | 25 |
|
26 | 26 | #define MAXIMUM_SUPPORTED_POINTS 10
|
27 | 27 | struct ft5406_regs {
|
@@ -49,23 +49,6 @@ struct ft5406 {
|
49 | 49 | struct task_struct * thread;
|
50 | 50 | };
|
51 | 51 |
|
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 |
| - |
69 | 52 | /* Thread to poll for touchscreen events
|
70 | 53 | *
|
71 | 54 | * This thread polls the memory based register copy of the ft5406 registers
|
@@ -136,11 +119,37 @@ static int ft5406_probe(struct platform_device *pdev)
|
136 | 119 | {
|
137 | 120 | int ret;
|
138 | 121 | struct input_dev * input_dev = input_allocate_device();
|
139 |
| - struct vc_msg request; |
140 | 122 | struct ft5406 * ts;
|
| 123 | + struct device_node *fw_node; |
| 124 | + struct rpi_firmware *fw; |
| 125 | + u32 touchbuf; |
141 | 126 |
|
142 | 127 | dev_info(&pdev->dev, "Probing device\n");
|
143 | 128 |
|
| 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 | + |
144 | 153 | ts = kzalloc(sizeof(struct ft5406), GFP_KERNEL);
|
145 | 154 |
|
146 | 155 | if (!ts || !input_dev) {
|
@@ -174,36 +183,15 @@ static int ft5406_probe(struct platform_device *pdev)
|
174 | 183 | return ret;
|
175 | 184 | }
|
176 | 185 |
|
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 |
| - |
198 | 186 | // 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)); |
201 | 189 | if(ts->ts_base == NULL)
|
202 | 190 | {
|
203 | 191 | dev_err(&pdev->dev, "Failed to map physical address\n");
|
204 | 192 | input_unregister_device(input_dev);
|
205 | 193 | kzfree(ts);
|
206 |
| - return -1; |
| 194 | + return -ENOMEM; |
207 | 195 | }
|
208 | 196 |
|
209 | 197 | ts->regs = (struct ft5406_regs *) ts->ts_base;
|
|
0 commit comments