1 From 0d63b8a00c925eb02093e9ed4866c4a0d9209a00 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <pelwell@users.noreply.github.com>
3 Date: Tue, 14 Jul 2015 14:32:47 +0100
4 Subject: [PATCH 064/806] mfd: Add Raspberry Pi Sense HAT core driver
7 drivers/input/joystick/Kconfig | 8 +
8 drivers/input/joystick/Makefile | 1 +
9 drivers/input/joystick/rpisense-js.c | 153 ++++++++++++
10 drivers/mfd/Kconfig | 8 +
11 drivers/mfd/Makefile | 2 +-
12 drivers/mfd/rpisense-core.c | 157 ++++++++++++
13 drivers/video/fbdev/Kconfig | 13 +
14 drivers/video/fbdev/Makefile | 1 +
15 drivers/video/fbdev/rpisense-fb.c | 293 +++++++++++++++++++++++
16 include/linux/mfd/rpisense/core.h | 47 ++++
17 include/linux/mfd/rpisense/framebuffer.h | 32 +++
18 include/linux/mfd/rpisense/joystick.h | 35 +++
19 12 files changed, 749 insertions(+), 1 deletion(-)
20 create mode 100644 drivers/input/joystick/rpisense-js.c
21 create mode 100644 drivers/mfd/rpisense-core.c
22 create mode 100644 drivers/video/fbdev/rpisense-fb.c
23 create mode 100644 include/linux/mfd/rpisense/core.h
24 create mode 100644 include/linux/mfd/rpisense/framebuffer.h
25 create mode 100644 include/linux/mfd/rpisense/joystick.h
27 --- a/drivers/input/joystick/Kconfig
28 +++ b/drivers/input/joystick/Kconfig
29 @@ -361,4 +361,12 @@ config JOYSTICK_PXRC
30 To compile this driver as a module, choose M here: the
31 module will be called pxrc.
33 +config JOYSTICK_RPISENSE
34 + tristate "Raspberry Pi Sense HAT joystick"
35 + depends on GPIOLIB && INPUT
36 + select MFD_RPISENSE_CORE
39 + This is the joystick driver for the Raspberry Pi Sense HAT
42 --- a/drivers/input/joystick/Makefile
43 +++ b/drivers/input/joystick/Makefile
44 @@ -35,4 +35,5 @@ obj-$(CONFIG_JOYSTICK_WARRIOR) += warri
45 obj-$(CONFIG_JOYSTICK_XPAD) += xpad.o
46 obj-$(CONFIG_JOYSTICK_ZHENHUA) += zhenhua.o
47 obj-$(CONFIG_JOYSTICK_WALKERA0701) += walkera0701.o
48 +obj-$(CONFIG_JOYSTICK_RPISENSE) += rpisense-js.o
51 +++ b/drivers/input/joystick/rpisense-js.c
54 + * Raspberry Pi Sense HAT joystick driver
55 + * http://raspberrypi.org
57 + * Copyright (C) 2015 Raspberry Pi
59 + * Author: Serge Schneider
61 + * This program is free software; you can redistribute it and/or modify it
62 + * under the terms of the GNU General Public License as published by the
63 + * Free Software Foundation; either version 2 of the License, or (at your
64 + * option) any later version.
68 +#include <linux/module.h>
70 +#include <linux/mfd/rpisense/joystick.h>
71 +#include <linux/mfd/rpisense/core.h>
73 +static struct rpisense *rpisense;
74 +static unsigned char keymap[5] = {KEY_DOWN, KEY_RIGHT, KEY_UP, KEY_ENTER, KEY_LEFT,};
76 +static void keys_work_fn(struct work_struct *work)
79 + static s32 prev_keys;
80 + struct rpisense_js *rpisense_js = &rpisense->joystick;
81 + s32 keys = rpisense_reg_read(rpisense, RPISENSE_KEYS);
82 + s32 changes = keys ^ prev_keys;
85 + for (i = 0; i < 5; i++) {
87 + input_report_key(rpisense_js->keys_dev,
88 + keymap[i], keys & 1);
93 + input_sync(rpisense_js->keys_dev);
96 +static irqreturn_t keys_irq_handler(int irq, void *pdev)
98 + struct rpisense_js *rpisense_js = &rpisense->joystick;
100 + schedule_work(&rpisense_js->keys_work_s);
101 + return IRQ_HANDLED;
104 +static int rpisense_js_probe(struct platform_device *pdev)
108 + struct rpisense_js *rpisense_js;
110 + rpisense = rpisense_get_dev();
111 + rpisense_js = &rpisense->joystick;
113 + INIT_WORK(&rpisense_js->keys_work_s, keys_work_fn);
115 + rpisense_js->keys_dev = input_allocate_device();
116 + if (!rpisense_js->keys_dev) {
117 + dev_err(&pdev->dev, "Could not allocate input device.\n");
121 + rpisense_js->keys_dev->evbit[0] = BIT_MASK(EV_KEY);
122 + for (i = 0; i < ARRAY_SIZE(keymap); i++) {
124 + rpisense_js->keys_dev->keybit);
127 + rpisense_js->keys_dev->name = "Raspberry Pi Sense HAT Joystick";
128 + rpisense_js->keys_dev->phys = "rpi-sense-joy/input0";
129 + rpisense_js->keys_dev->id.bustype = BUS_I2C;
130 + rpisense_js->keys_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
131 + rpisense_js->keys_dev->keycode = keymap;
132 + rpisense_js->keys_dev->keycodesize = sizeof(unsigned char);
133 + rpisense_js->keys_dev->keycodemax = ARRAY_SIZE(keymap);
135 + ret = input_register_device(rpisense_js->keys_dev);
137 + dev_err(&pdev->dev, "Could not register input device.\n");
138 + goto err_keys_alloc;
141 + ret = gpiod_direction_input(rpisense_js->keys_desc);
143 + dev_err(&pdev->dev, "Could not set keys-int direction.\n");
147 + rpisense_js->keys_irq = gpiod_to_irq(rpisense_js->keys_desc);
148 + if (rpisense_js->keys_irq < 0) {
149 + dev_err(&pdev->dev, "Could not determine keys-int IRQ.\n");
150 + ret = rpisense_js->keys_irq;
154 + ret = devm_request_irq(&pdev->dev, rpisense_js->keys_irq,
155 + keys_irq_handler, IRQF_TRIGGER_RISING,
156 + "keys", &pdev->dev);
158 + dev_err(&pdev->dev, "IRQ request failed.\n");
163 + input_unregister_device(rpisense_js->keys_dev);
165 + input_free_device(rpisense_js->keys_dev);
169 +static int rpisense_js_remove(struct platform_device *pdev)
171 + struct rpisense_js *rpisense_js = &rpisense->joystick;
173 + input_unregister_device(rpisense_js->keys_dev);
174 + input_free_device(rpisense_js->keys_dev);
179 +static const struct of_device_id rpisense_js_id[] = {
180 + { .compatible = "rpi,rpi-sense-js" },
183 +MODULE_DEVICE_TABLE(of, rpisense_js_id);
186 +static struct platform_device_id rpisense_js_device_id[] = {
187 + { .name = "rpi-sense-js" },
190 +MODULE_DEVICE_TABLE(platform, rpisense_js_device_id);
192 +static struct platform_driver rpisense_js_driver = {
193 + .probe = rpisense_js_probe,
194 + .remove = rpisense_js_remove,
196 + .name = "rpi-sense-js",
197 + .owner = THIS_MODULE,
201 +module_platform_driver(rpisense_js_driver);
203 +MODULE_DESCRIPTION("Raspberry Pi Sense HAT joystick driver");
204 +MODULE_AUTHOR("Serge Schneider <serge@raspberrypi.org>");
205 +MODULE_LICENSE("GPL");
206 --- a/drivers/mfd/Kconfig
207 +++ b/drivers/mfd/Kconfig
208 @@ -10,6 +10,14 @@ config MFD_CORE
212 +config MFD_RPISENSE_CORE
213 + tristate "Raspberry Pi Sense HAT core functions"
217 + This is the core driver for the Raspberry Pi Sense HAT. This provides
218 + the necessary functions to communicate with the hardware.
221 tristate "AMD CS5535 and CS5536 southbridge core functions"
223 --- a/drivers/mfd/Makefile
224 +++ b/drivers/mfd/Makefile
225 @@ -240,4 +240,4 @@ obj-$(CONFIG_MFD_MXS_LRADC) += mxs-l
226 obj-$(CONFIG_MFD_SC27XX_PMIC) += sprd-sc27xx-spi.o
227 obj-$(CONFIG_RAVE_SP_CORE) += rave-sp.o
228 obj-$(CONFIG_MFD_ROHM_BD718XX) += rohm-bd718x7.o
230 +obj-$(CONFIG_MFD_RPISENSE_CORE) += rpisense-core.o
232 +++ b/drivers/mfd/rpisense-core.c
235 + * Raspberry Pi Sense HAT core driver
236 + * http://raspberrypi.org
238 + * Copyright (C) 2015 Raspberry Pi
240 + * Author: Serge Schneider
242 + * This program is free software; you can redistribute it and/or modify it
243 + * under the terms of the GNU General Public License as published by the
244 + * Free Software Foundation; either version 2 of the License, or (at your
245 + * option) any later version.
247 + * This driver is based on wm8350 implementation.
250 +#include <linux/module.h>
251 +#include <linux/moduleparam.h>
252 +#include <linux/err.h>
253 +#include <linux/init.h>
254 +#include <linux/i2c.h>
255 +#include <linux/platform_device.h>
256 +#include <linux/mfd/rpisense/core.h>
257 +#include <linux/slab.h>
259 +static struct rpisense *rpisense;
261 +static void rpisense_client_dev_register(struct rpisense *rpisense,
263 + struct platform_device **pdev)
267 + *pdev = platform_device_alloc(name, -1);
268 + if (*pdev == NULL) {
269 + dev_err(rpisense->dev, "Failed to allocate %s\n", name);
273 + (*pdev)->dev.parent = rpisense->dev;
274 + platform_set_drvdata(*pdev, rpisense);
275 + ret = platform_device_add(*pdev);
277 + dev_err(rpisense->dev, "Failed to register %s: %d\n",
279 + platform_device_put(*pdev);
284 +static int rpisense_probe(struct i2c_client *i2c,
285 + const struct i2c_device_id *id)
288 + struct rpisense_js *rpisense_js;
290 + rpisense = devm_kzalloc(&i2c->dev, sizeof(struct rpisense), GFP_KERNEL);
291 + if (rpisense == NULL)
294 + i2c_set_clientdata(i2c, rpisense);
295 + rpisense->dev = &i2c->dev;
296 + rpisense->i2c_client = i2c;
298 + ret = rpisense_reg_read(rpisense, RPISENSE_WAI);
305 + ret = rpisense_reg_read(rpisense, RPISENSE_VER);
309 + dev_info(rpisense->dev,
310 + "Raspberry Pi Sense HAT firmware version %i\n", ret);
312 + rpisense_js = &rpisense->joystick;
313 + rpisense_js->keys_desc = devm_gpiod_get(&i2c->dev,
314 + "keys-int", GPIOD_IN);
315 + if (IS_ERR(rpisense_js->keys_desc)) {
316 + dev_warn(&i2c->dev, "Failed to get keys-int descriptor.\n");
317 + rpisense_js->keys_desc = gpio_to_desc(23);
318 + if (rpisense_js->keys_desc == NULL) {
319 + dev_err(&i2c->dev, "GPIO23 fallback failed.\n");
320 + return PTR_ERR(rpisense_js->keys_desc);
323 + rpisense_client_dev_register(rpisense, "rpi-sense-js",
324 + &(rpisense->joystick.pdev));
325 + rpisense_client_dev_register(rpisense, "rpi-sense-fb",
326 + &(rpisense->framebuffer.pdev));
331 +static int rpisense_remove(struct i2c_client *i2c)
333 + struct rpisense *rpisense = i2c_get_clientdata(i2c);
335 + platform_device_unregister(rpisense->joystick.pdev);
339 +struct rpisense *rpisense_get_dev(void)
343 +EXPORT_SYMBOL_GPL(rpisense_get_dev);
345 +s32 rpisense_reg_read(struct rpisense *rpisense, int reg)
347 + int ret = i2c_smbus_read_byte_data(rpisense->i2c_client, reg);
350 + dev_err(rpisense->dev, "Read from reg %d failed\n", reg);
351 + /* Due to the BCM270x I2C clock stretching bug, some values
352 + * may have MSB set. Clear it to avoid incorrect values.
356 +EXPORT_SYMBOL_GPL(rpisense_reg_read);
358 +int rpisense_block_write(struct rpisense *rpisense, const char *buf, int count)
360 + int ret = i2c_master_send(rpisense->i2c_client, buf, count);
363 + dev_err(rpisense->dev, "Block write failed\n");
366 +EXPORT_SYMBOL_GPL(rpisense_block_write);
368 +static const struct i2c_device_id rpisense_i2c_id[] = {
369 + { "rpi-sense", 0 },
372 +MODULE_DEVICE_TABLE(i2c, rpisense_i2c_id);
375 +static struct i2c_driver rpisense_driver = {
377 + .name = "rpi-sense",
378 + .owner = THIS_MODULE,
380 + .probe = rpisense_probe,
381 + .remove = rpisense_remove,
382 + .id_table = rpisense_i2c_id,
385 +module_i2c_driver(rpisense_driver);
387 +MODULE_DESCRIPTION("Raspberry Pi Sense HAT core driver");
388 +MODULE_AUTHOR("Serge Schneider <serge@raspberrypi.org>");
389 +MODULE_LICENSE("GPL");
391 --- a/drivers/video/fbdev/Kconfig
392 +++ b/drivers/video/fbdev/Kconfig
393 @@ -2350,6 +2350,19 @@ config FB_SM712
394 called sm712fb. If you want to compile it as a module, say M
395 here and read <file:Documentation/kbuild/modules.txt>.
398 + tristate "Raspberry Pi Sense HAT framebuffer"
400 + select MFD_RPISENSE_CORE
402 + select FB_SYS_FILLRECT
403 + select FB_SYS_COPYAREA
404 + select FB_SYS_IMAGEBLIT
405 + select FB_DEFERRED_IO
408 + This is the framebuffer driver for the Raspberry Pi Sense HAT
410 source "drivers/video/fbdev/omap/Kconfig"
411 source "drivers/video/fbdev/omap2/Kconfig"
412 source "drivers/video/fbdev/mmp/Kconfig"
413 --- a/drivers/video/fbdev/Makefile
414 +++ b/drivers/video/fbdev/Makefile
415 @@ -138,6 +138,7 @@ obj-$(CONFIG_FB_DA8XX) += da8xx-fb.o
416 obj-$(CONFIG_FB_MXS) += mxsfb.o
417 obj-$(CONFIG_FB_SSD1307) += ssd1307fb.o
418 obj-$(CONFIG_FB_SIMPLE) += simplefb.o
419 +obj-$(CONFIG_FB_RPISENSE) += rpisense-fb.o
421 # the test framebuffer is last
422 obj-$(CONFIG_FB_VIRTUAL) += vfb.o
424 +++ b/drivers/video/fbdev/rpisense-fb.c
427 + * Raspberry Pi Sense HAT framebuffer driver
428 + * http://raspberrypi.org
430 + * Copyright (C) 2015 Raspberry Pi
432 + * Author: Serge Schneider
434 + * This program is free software; you can redistribute it and/or modify it
435 + * under the terms of the GNU General Public License as published by the
436 + * Free Software Foundation; either version 2 of the License, or (at your
437 + * option) any later version.
441 +#include <linux/module.h>
442 +#include <linux/kernel.h>
443 +#include <linux/errno.h>
444 +#include <linux/string.h>
445 +#include <linux/mm.h>
446 +#include <linux/slab.h>
447 +#include <linux/uaccess.h>
448 +#include <linux/delay.h>
449 +#include <linux/fb.h>
450 +#include <linux/init.h>
452 +#include <linux/mfd/rpisense/framebuffer.h>
453 +#include <linux/mfd/rpisense/core.h>
455 +static bool lowlight;
456 +module_param(lowlight, bool, 0);
457 +MODULE_PARM_DESC(lowlight, "Reduce LED matrix brightness to one third");
459 +static struct rpisense *rpisense;
461 +struct rpisense_fb_param {
462 + char __iomem *vmem;
468 +static u8 gamma_default[32] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
469 + 0x02, 0x02, 0x03, 0x03, 0x04, 0x05, 0x06, 0x07,
470 + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0E, 0x0F, 0x11,
471 + 0x12, 0x14, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F,};
473 +static u8 gamma_low[32] = {0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
474 + 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02,
475 + 0x03, 0x03, 0x03, 0x04, 0x04, 0x05, 0x05, 0x06,
476 + 0x06, 0x07, 0x07, 0x08, 0x08, 0x09, 0x0A, 0x0A,};
478 +static u8 gamma_user[32];
480 +static struct rpisense_fb_param rpisense_fb_param = {
483 + .gamma = gamma_default,
486 +static struct fb_deferred_io rpisense_fb_defio;
488 +static struct fb_fix_screeninfo rpisense_fb_fix = {
489 + .id = "RPi-Sense FB",
490 + .type = FB_TYPE_PACKED_PIXELS,
491 + .visual = FB_VISUAL_TRUECOLOR,
495 + .accel = FB_ACCEL_NONE,
499 +static struct fb_var_screeninfo rpisense_fb_var = {
504 + .bits_per_pixel = 16,
506 + .green = {5, 6, 0},
510 +static ssize_t rpisense_fb_write(struct fb_info *info,
511 + const char __user *buf, size_t count,
514 + ssize_t res = fb_sys_write(info, buf, count, ppos);
516 + schedule_delayed_work(&info->deferred_work, rpisense_fb_defio.delay);
520 +static void rpisense_fb_fillrect(struct fb_info *info,
521 + const struct fb_fillrect *rect)
523 + sys_fillrect(info, rect);
524 + schedule_delayed_work(&info->deferred_work, rpisense_fb_defio.delay);
527 +static void rpisense_fb_copyarea(struct fb_info *info,
528 + const struct fb_copyarea *area)
530 + sys_copyarea(info, area);
531 + schedule_delayed_work(&info->deferred_work, rpisense_fb_defio.delay);
534 +static void rpisense_fb_imageblit(struct fb_info *info,
535 + const struct fb_image *image)
537 + sys_imageblit(info, image);
538 + schedule_delayed_work(&info->deferred_work, rpisense_fb_defio.delay);
541 +static void rpisense_fb_deferred_io(struct fb_info *info,
542 + struct list_head *pagelist)
546 + u8 *vmem_work = rpisense_fb_param.vmem_work;
547 + u16 *mem = (u16 *)rpisense_fb_param.vmem;
548 + u8 *gamma = rpisense_fb_param.gamma;
551 + for (j = 0; j < 8; j++) {
552 + for (i = 0; i < 8; i++) {
553 + vmem_work[(j * 24) + i + 1] =
554 + gamma[(mem[(j * 8) + i] >> 11) & 0x1F];
555 + vmem_work[(j * 24) + (i + 8) + 1] =
556 + gamma[(mem[(j * 8) + i] >> 6) & 0x1F];
557 + vmem_work[(j * 24) + (i + 16) + 1] =
558 + gamma[(mem[(j * 8) + i]) & 0x1F];
561 + rpisense_block_write(rpisense, vmem_work, 193);
564 +static struct fb_deferred_io rpisense_fb_defio = {
566 + .deferred_io = rpisense_fb_deferred_io,
569 +static int rpisense_fb_ioctl(struct fb_info *info, unsigned int cmd,
573 + case SENSEFB_FBIOGET_GAMMA:
574 + if (copy_to_user((void __user *) arg, rpisense_fb_param.gamma,
578 + case SENSEFB_FBIOSET_GAMMA:
579 + if (copy_from_user(gamma_user, (void __user *)arg,
582 + rpisense_fb_param.gamma = gamma_user;
583 + schedule_delayed_work(&info->deferred_work,
584 + rpisense_fb_defio.delay);
586 + case SENSEFB_FBIORESET_GAMMA:
589 + rpisense_fb_param.gamma = gamma_default;
592 + rpisense_fb_param.gamma = gamma_low;
595 + rpisense_fb_param.gamma = gamma_user;
600 + schedule_delayed_work(&info->deferred_work,
601 + rpisense_fb_defio.delay);
609 +static struct fb_ops rpisense_fb_ops = {
610 + .owner = THIS_MODULE,
611 + .fb_read = fb_sys_read,
612 + .fb_write = rpisense_fb_write,
613 + .fb_fillrect = rpisense_fb_fillrect,
614 + .fb_copyarea = rpisense_fb_copyarea,
615 + .fb_imageblit = rpisense_fb_imageblit,
616 + .fb_ioctl = rpisense_fb_ioctl,
619 +static int rpisense_fb_probe(struct platform_device *pdev)
621 + struct fb_info *info;
623 + struct rpisense_fb *rpisense_fb;
625 + rpisense = rpisense_get_dev();
626 + rpisense_fb = &rpisense->framebuffer;
628 + rpisense_fb_param.vmem = vzalloc(rpisense_fb_param.vmemsize);
629 + if (!rpisense_fb_param.vmem)
632 + rpisense_fb_param.vmem_work = devm_kmalloc(&pdev->dev, 193, GFP_KERNEL);
633 + if (!rpisense_fb_param.vmem_work)
636 + info = framebuffer_alloc(0, &pdev->dev);
638 + dev_err(&pdev->dev, "Could not allocate framebuffer.\n");
641 + rpisense_fb->info = info;
643 + rpisense_fb_fix.smem_start = (unsigned long)rpisense_fb_param.vmem;
644 + rpisense_fb_fix.smem_len = rpisense_fb_param.vmemsize;
646 + info->fbops = &rpisense_fb_ops;
647 + info->fix = rpisense_fb_fix;
648 + info->var = rpisense_fb_var;
649 + info->fbdefio = &rpisense_fb_defio;
650 + info->flags = FBINFO_FLAG_DEFAULT | FBINFO_VIRTFB;
651 + info->screen_base = rpisense_fb_param.vmem;
652 + info->screen_size = rpisense_fb_param.vmemsize;
655 + rpisense_fb_param.gamma = gamma_low;
657 + fb_deferred_io_init(info);
659 + ret = register_framebuffer(info);
661 + dev_err(&pdev->dev, "Could not register framebuffer.\n");
665 + fb_info(info, "%s frame buffer device\n", info->fix.id);
666 + schedule_delayed_work(&info->deferred_work, rpisense_fb_defio.delay);
669 + framebuffer_release(info);
671 + vfree(rpisense_fb_param.vmem);
675 +static int rpisense_fb_remove(struct platform_device *pdev)
677 + struct rpisense_fb *rpisense_fb = &rpisense->framebuffer;
678 + struct fb_info *info = rpisense_fb->info;
681 + unregister_framebuffer(info);
682 + fb_deferred_io_cleanup(info);
683 + framebuffer_release(info);
684 + vfree(rpisense_fb_param.vmem);
691 +static const struct of_device_id rpisense_fb_id[] = {
692 + { .compatible = "rpi,rpi-sense-fb" },
695 +MODULE_DEVICE_TABLE(of, rpisense_fb_id);
698 +static struct platform_device_id rpisense_fb_device_id[] = {
699 + { .name = "rpi-sense-fb" },
702 +MODULE_DEVICE_TABLE(platform, rpisense_fb_device_id);
704 +static struct platform_driver rpisense_fb_driver = {
705 + .probe = rpisense_fb_probe,
706 + .remove = rpisense_fb_remove,
708 + .name = "rpi-sense-fb",
709 + .owner = THIS_MODULE,
713 +module_platform_driver(rpisense_fb_driver);
715 +MODULE_DESCRIPTION("Raspberry Pi Sense HAT framebuffer driver");
716 +MODULE_AUTHOR("Serge Schneider <serge@raspberrypi.org>");
717 +MODULE_LICENSE("GPL");
720 +++ b/include/linux/mfd/rpisense/core.h
723 + * Raspberry Pi Sense HAT core driver
724 + * http://raspberrypi.org
726 + * Copyright (C) 2015 Raspberry Pi
728 + * Author: Serge Schneider
730 + * This program is free software; you can redistribute it and/or modify it
731 + * under the terms of the GNU General Public License as published by the
732 + * Free Software Foundation; either version 2 of the License, or (at your
733 + * option) any later version.
737 +#ifndef __LINUX_MFD_RPISENSE_CORE_H_
738 +#define __LINUX_MFD_RPISENSE_CORE_H_
740 +#include <linux/mfd/rpisense/joystick.h>
741 +#include <linux/mfd/rpisense/framebuffer.h>
746 +#define RPISENSE_FB 0x00
747 +#define RPISENSE_WAI 0xF0
748 +#define RPISENSE_VER 0xF1
749 +#define RPISENSE_KEYS 0xF2
750 +#define RPISENSE_EE_WP 0xF3
752 +#define RPISENSE_ID 's'
755 + struct device *dev;
756 + struct i2c_client *i2c_client;
758 + /* Client devices */
759 + struct rpisense_js joystick;
760 + struct rpisense_fb framebuffer;
763 +struct rpisense *rpisense_get_dev(void);
764 +s32 rpisense_reg_read(struct rpisense *rpisense, int reg);
765 +int rpisense_reg_write(struct rpisense *rpisense, int reg, u16 val);
766 +int rpisense_block_write(struct rpisense *rpisense, const char *buf, int count);
770 +++ b/include/linux/mfd/rpisense/framebuffer.h
773 + * Raspberry Pi Sense HAT framebuffer driver
774 + * http://raspberrypi.org
776 + * Copyright (C) 2015 Raspberry Pi
778 + * Author: Serge Schneider
780 + * This program is free software; you can redistribute it and/or modify it
781 + * under the terms of the GNU General Public License as published by the
782 + * Free Software Foundation; either version 2 of the License, or (at your
783 + * option) any later version.
787 +#ifndef __LINUX_RPISENSE_FB_H_
788 +#define __LINUX_RPISENSE_FB_H_
790 +#define SENSEFB_FBIO_IOC_MAGIC 0xF1
792 +#define SENSEFB_FBIOGET_GAMMA _IO(SENSEFB_FBIO_IOC_MAGIC, 0)
793 +#define SENSEFB_FBIOSET_GAMMA _IO(SENSEFB_FBIO_IOC_MAGIC, 1)
794 +#define SENSEFB_FBIORESET_GAMMA _IO(SENSEFB_FBIO_IOC_MAGIC, 2)
798 +struct rpisense_fb {
799 + struct platform_device *pdev;
800 + struct fb_info *info;
805 +++ b/include/linux/mfd/rpisense/joystick.h
808 + * Raspberry Pi Sense HAT joystick driver
809 + * http://raspberrypi.org
811 + * Copyright (C) 2015 Raspberry Pi
813 + * Author: Serge Schneider
815 + * This program is free software; you can redistribute it and/or modify it
816 + * under the terms of the GNU General Public License as published by the
817 + * Free Software Foundation; either version 2 of the License, or (at your
818 + * option) any later version.
822 +#ifndef __LINUX_RPISENSE_JOYSTICK_H_
823 +#define __LINUX_RPISENSE_JOYSTICK_H_
825 +#include <linux/input.h>
826 +#include <linux/interrupt.h>
827 +#include <linux/gpio/consumer.h>
828 +#include <linux/platform_device.h>
832 +struct rpisense_js {
833 + struct platform_device *pdev;
834 + struct input_dev *keys_dev;
835 + struct gpio_desc *keys_desc;
836 + struct work_struct keys_work_s;