diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-05-04 19:07:10 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-05-04 19:15:35 -0700 |
commit | af82455f7dbd9dc20244d80d033721b30d22c065 (patch) | |
tree | 3b9246456e82ae116b57834a2f0b4a307a016474 /drivers/misc | |
parent | 0be75179df5e20306528800fc7c6a504b12b97db (diff) | |
parent | 2a76f89fa58c769241cfc21f2614705591519ae3 (diff) |
Merge tag 'char-misc-4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver updates from Greg KH:
"Here is the big set of new char/misc driver drivers and features for
4.12-rc1.
There's lots of new drivers added this time around, new firmware
drivers from Google, more auxdisplay drivers, extcon drivers, fpga
drivers, and a bunch of other driver updates. Nothing major, except if
you happen to have the hardware for these drivers, and then you will
be happy :)
All of these have been in linux-next for a while with no reported
issues"
* tag 'char-misc-4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (136 commits)
firmware: google memconsole: Fix return value check in platform_memconsole_init()
firmware: Google VPD: Fix return value check in vpd_platform_init()
goldfish_pipe: fix build warning about using too much stack.
goldfish_pipe: An implementation of more parallel pipe
fpga fr br: update supported version numbers
fpga: region: release FPGA region reference in error path
fpga altera-hps2fpga: disable/unprepare clock on error in alt_fpga_bridge_probe()
mei: drop the TODO from samples
firmware: Google VPD sysfs driver
firmware: Google VPD: import lib_vpd source files
misc: lkdtm: Add volatile to intentional NULL pointer reference
eeprom: idt_89hpesx: Add OF device ID table
misc: ds1682: Add OF device ID table
misc: tsl2550: Add OF device ID table
w1: Remove unneeded use of assert() and remove w1_log.h
w1: Use kernel common min() implementation
uio_mf624: Align memory regions to page size and set correct offsets
uio_mf624: Refactor memory info initialization
uio: Allow handling of non page-aligned memory regions
hangcheck-timer: Fix typo in comment
...
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/Kconfig | 293 | ||||
-rw-r--r-- | drivers/misc/Makefile | 5 | ||||
-rw-r--r-- | drivers/misc/arm-charlcd.c | 368 | ||||
-rw-r--r-- | drivers/misc/aspeed-lpc-ctrl.c | 266 | ||||
-rw-r--r-- | drivers/misc/ds1682.c | 7 | ||||
-rw-r--r-- | drivers/misc/eeprom/idt_89hpesx.c | 57 | ||||
-rw-r--r-- | drivers/misc/lkdtm.h | 1 | ||||
-rw-r--r-- | drivers/misc/lkdtm_bugs.c | 13 | ||||
-rw-r--r-- | drivers/misc/lkdtm_core.c | 1 | ||||
-rw-r--r-- | drivers/misc/mei/Makefile | 1 | ||||
-rw-r--r-- | drivers/misc/mei/amthif.c | 340 | ||||
-rw-r--r-- | drivers/misc/mei/bus-fixup.c | 9 | ||||
-rw-r--r-- | drivers/misc/mei/bus.c | 6 | ||||
-rw-r--r-- | drivers/misc/mei/client.c | 14 | ||||
-rw-r--r-- | drivers/misc/mei/client.h | 5 | ||||
-rw-r--r-- | drivers/misc/mei/hbm.c | 29 | ||||
-rw-r--r-- | drivers/misc/mei/init.c | 14 | ||||
-rw-r--r-- | drivers/misc/mei/interrupt.c | 38 | ||||
-rw-r--r-- | drivers/misc/mei/main.c | 125 | ||||
-rw-r--r-- | drivers/misc/mei/mei_dev.h | 51 | ||||
-rw-r--r-- | drivers/misc/mei/pci-me.c | 31 | ||||
-rw-r--r-- | drivers/misc/mei/pci-txe.c | 29 | ||||
-rw-r--r-- | drivers/misc/panel.c | 2439 | ||||
-rw-r--r-- | drivers/misc/tsl2550.c | 7 |
24 files changed, 523 insertions, 3626 deletions
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index c290990d73ed..39d1acb27452 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -419,16 +419,6 @@ config VMWARE_BALLOON To compile this driver as a module, choose M here: the module will be called vmw_balloon. -config ARM_CHARLCD - bool "ARM Ltd. Character LCD Driver" - depends on PLAT_VERSATILE - help - This is a driver for the character LCD found on the ARM Ltd. - Versatile and RealView Platform Baseboards. It doesn't do - very much more than display the text "ARM Linux" on the first - line and the Linux version on the second line, but that's - still useful. - config PCH_PHUB tristate "Intel EG20T PCH/LAPIS Semicon IOH(ML7213/ML7223/ML7831) PHUB" select GENERIC_NET_UTILS @@ -492,284 +482,13 @@ config VEXPRESS_SYSCFG bus. System Configuration interface is one of the possible means of generating transactions on this bus. -config PANEL - tristate "Parallel port LCD/Keypad Panel support" - depends on PARPORT - ---help--- - Say Y here if you have an HD44780 or KS-0074 LCD connected to your - parallel port. This driver also features 4 and 6-key keypads. The LCD - is accessible through the /dev/lcd char device (10, 156), and the - keypad through /dev/keypad (10, 185). This code can either be - compiled as a module, or linked into the kernel and started at boot. - If you don't understand what all this is about, say N. - -if PANEL - -config PANEL_PARPORT - int "Default parallel port number (0=LPT1)" - range 0 255 - default "0" - ---help--- - This is the index of the parallel port the panel is connected to. One - driver instance only supports one parallel port, so if your keypad - and LCD are connected to two separate ports, you have to start two - modules with different arguments. Numbering starts with '0' for LPT1, - and so on. - -config PANEL_PROFILE - int "Default panel profile (0-5, 0=custom)" - range 0 5 - default "5" - ---help--- - To ease configuration, the driver supports different configuration - profiles for past and recent wirings. These profiles can also be - used to define an approximative configuration, completed by a few - other options. Here are the profiles : - - 0 = custom (see further) - 1 = 2x16 parallel LCD, old keypad - 2 = 2x16 serial LCD (KS-0074), new keypad - 3 = 2x16 parallel LCD (Hantronix), no keypad - 4 = 2x16 parallel LCD (Nexcom NSA1045) with Nexcom's keypad - 5 = 2x40 parallel LCD (old one), with old keypad - - Custom configurations allow you to define how your display is - wired to the parallel port, and how it works. This is only intended - for experts. - -config PANEL_KEYPAD - depends on PANEL_PROFILE="0" - int "Keypad type (0=none, 1=old 6 keys, 2=new 6 keys, 3=Nexcom 4 keys)" - range 0 3 - default 0 - ---help--- - This enables and configures a keypad connected to the parallel port. - The keys will be read from character device 10,185. Valid values are : - - 0 : do not enable this driver - 1 : old 6 keys keypad - 2 : new 6 keys keypad, as used on the server at www.ant-computing.com - 3 : Nexcom NSA1045's 4 keys keypad - - New profiles can be described in the driver source. The driver also - supports simultaneous keys pressed when the keypad supports them. - -config PANEL_LCD - depends on PANEL_PROFILE="0" - int "LCD type (0=none, 1=custom, 2=old //, 3=ks0074, 4=hantronix, 5=Nexcom)" - range 0 5 - default 0 - ---help--- - This enables and configures an LCD connected to the parallel port. - The driver includes an interpreter for escape codes starting with - '\e[L' which are specific to the LCD, and a few ANSI codes. The - driver will be registered as character device 10,156, usually - under the name '/dev/lcd'. There are a total of 6 supported types : - - 0 : do not enable the driver - 1 : custom configuration and wiring (see further) - 2 : 2x16 & 2x40 parallel LCD (old wiring) - 3 : 2x16 serial LCD (KS-0074 based) - 4 : 2x16 parallel LCD (Hantronix wiring) - 5 : 2x16 parallel LCD (Nexcom wiring) - - When type '1' is specified, other options will appear to configure - more precise aspects (wiring, dimensions, protocol, ...). Please note - that those values changed from the 2.4 driver for better consistency. - -config PANEL_LCD_HEIGHT - depends on PANEL_PROFILE="0" && PANEL_LCD="1" - int "Number of lines on the LCD (1-2)" - range 1 2 - default 2 - ---help--- - This is the number of visible character lines on the LCD in custom profile. - It can either be 1 or 2. - -config PANEL_LCD_WIDTH - depends on PANEL_PROFILE="0" && PANEL_LCD="1" - int "Number of characters per line on the LCD (1-40)" - range 1 40 - default 40 - ---help--- - This is the number of characters per line on the LCD in custom profile. - Common values are 16,20,24,40. - -config PANEL_LCD_BWIDTH - depends on PANEL_PROFILE="0" && PANEL_LCD="1" - int "Internal LCD line width (1-40, 40 by default)" - range 1 40 - default 40 - ---help--- - Most LCDs use a standard controller which supports hardware lines of 40 - characters, although sometimes only 16, 20 or 24 of them are really wired - to the terminal. This results in some non-visible but addressable characters, - and is the case for most parallel LCDs. Other LCDs, and some serial ones, - however, use the same line width internally as what is visible. The KS0074 - for example, uses 16 characters per line for 16 visible characters per line. - - This option lets you configure the value used by your LCD in 'custom' profile. - If you don't know, put '40' here. - -config PANEL_LCD_HWIDTH - depends on PANEL_PROFILE="0" && PANEL_LCD="1" - int "Hardware LCD line width (1-64, 64 by default)" - range 1 64 - default 64 - ---help--- - Most LCDs use a single address bit to differentiate line 0 and line 1. Since - some of them need to be able to address 40 chars with the lower bits, they - often use the immediately superior power of 2, which is 64, to address the - next line. - - If you don't know what your LCD uses, in doubt let 16 here for a 2x16, and - 64 here for a 2x40. - -config PANEL_LCD_CHARSET - depends on PANEL_PROFILE="0" && PANEL_LCD="1" - int "LCD character set (0=normal, 1=KS0074)" - range 0 1 - default 0 - ---help--- - Some controllers such as the KS0074 use a somewhat strange character set - where many symbols are at unusual places. The driver knows how to map - 'standard' ASCII characters to the character sets used by these controllers. - Valid values are : - - 0 : normal (untranslated) character set - 1 : KS0074 character set - - If you don't know, use the normal one (0). - -config PANEL_LCD_PROTO - depends on PANEL_PROFILE="0" && PANEL_LCD="1" - int "LCD communication mode (0=parallel 8 bits, 1=serial)" - range 0 1 - default 0 - ---help--- - This driver now supports any serial or parallel LCD wired to a parallel - port. But before assigning signals, the driver needs to know if it will - be driving a serial LCD or a parallel one. Serial LCDs only use 2 wires - (SDA/SCL), while parallel ones use 2 or 3 wires for the control signals - (E, RS, sometimes RW), and 4 or 8 for the data. Use 0 here for a 8 bits - parallel LCD, and 1 for a serial LCD. - -config PANEL_LCD_PIN_E - depends on PANEL_PROFILE="0" && PANEL_LCD="1" && PANEL_LCD_PROTO="0" - int "Parallel port pin number & polarity connected to the LCD E signal (-17...17) " - range -17 17 - default 14 +config ASPEED_LPC_CTRL + depends on (ARCH_ASPEED || COMPILE_TEST) && REGMAP && MFD_SYSCON + tristate "Aspeed ast2400/2500 HOST LPC to BMC bridge control" ---help--- - This describes the number of the parallel port pin to which the LCD 'E' - signal has been connected. It can be : - - 0 : no connection (eg: connected to ground) - 1..17 : directly connected to any of these pins on the DB25 plug - -1..-17 : connected to the same pin through an inverter (eg: transistor). - - Default for the 'E' pin in custom profile is '14' (AUTOFEED). - -config PANEL_LCD_PIN_RS - depends on PANEL_PROFILE="0" && PANEL_LCD="1" && PANEL_LCD_PROTO="0" - int "Parallel port pin number & polarity connected to the LCD RS signal (-17...17) " - range -17 17 - default 17 - ---help--- - This describes the number of the parallel port pin to which the LCD 'RS' - signal has been connected. It can be : - - 0 : no connection (eg: connected to ground) - 1..17 : directly connected to any of these pins on the DB25 plug - -1..-17 : connected to the same pin through an inverter (eg: transistor). - - Default for the 'RS' pin in custom profile is '17' (SELECT IN). - -config PANEL_LCD_PIN_RW - depends on PANEL_PROFILE="0" && PANEL_LCD="1" && PANEL_LCD_PROTO="0" - int "Parallel port pin number & polarity connected to the LCD RW signal (-17...17) " - range -17 17 - default 16 - ---help--- - This describes the number of the parallel port pin to which the LCD 'RW' - signal has been connected. It can be : - - 0 : no connection (eg: connected to ground) - 1..17 : directly connected to any of these pins on the DB25 plug - -1..-17 : connected to the same pin through an inverter (eg: transistor). - - Default for the 'RW' pin in custom profile is '16' (INIT). - -config PANEL_LCD_PIN_SCL - depends on PANEL_PROFILE="0" && PANEL_LCD="1" && PANEL_LCD_PROTO!="0" - int "Parallel port pin number & polarity connected to the LCD SCL signal (-17...17) " - range -17 17 - default 1 - ---help--- - This describes the number of the parallel port pin to which the serial - LCD 'SCL' signal has been connected. It can be : - - 0 : no connection (eg: connected to ground) - 1..17 : directly connected to any of these pins on the DB25 plug - -1..-17 : connected to the same pin through an inverter (eg: transistor). - - Default for the 'SCL' pin in custom profile is '1' (STROBE). - -config PANEL_LCD_PIN_SDA - depends on PANEL_PROFILE="0" && PANEL_LCD="1" && PANEL_LCD_PROTO!="0" - int "Parallel port pin number & polarity connected to the LCD SDA signal (-17...17) " - range -17 17 - default 2 - ---help--- - This describes the number of the parallel port pin to which the serial - LCD 'SDA' signal has been connected. It can be : - - 0 : no connection (eg: connected to ground) - 1..17 : directly connected to any of these pins on the DB25 plug - -1..-17 : connected to the same pin through an inverter (eg: transistor). - - Default for the 'SDA' pin in custom profile is '2' (D0). - -config PANEL_LCD_PIN_BL - depends on PANEL_PROFILE="0" && PANEL_LCD="1" - int "Parallel port pin number & polarity connected to the LCD backlight signal (-17...17) " - range -17 17 - default 0 - ---help--- - This describes the number of the parallel port pin to which the LCD 'BL' signal - has been connected. It can be : - - 0 : no connection (eg: connected to ground) - 1..17 : directly connected to any of these pins on the DB25 plug - -1..-17 : connected to the same pin through an inverter (eg: transistor). - - Default for the 'BL' pin in custom profile is '0' (uncontrolled). - -config PANEL_CHANGE_MESSAGE - bool "Change LCD initialization message ?" - default "n" - ---help--- - This allows you to replace the boot message indicating the kernel version - and the driver version with a custom message. This is useful on appliances - where a simple 'Starting system' message can be enough to stop a customer - from worrying. - - If you say 'Y' here, you'll be able to choose a message yourself. Otherwise, - say 'N' and keep the default message with the version. - -config PANEL_BOOT_MESSAGE - depends on PANEL_CHANGE_MESSAGE="y" - string "New initialization message" - default "" - ---help--- - This allows you to replace the boot message indicating the kernel version - and the driver version with a custom message. This is useful on appliances - where a simple 'Starting system' message can be enough to stop a customer - from worrying. - - An empty message will only clear the display at driver init time. Any other - printf()-formatted message is valid with newline and escape codes. - -endif # PANEL + Control Aspeed ast2400/2500 HOST LPC to BMC mappings through + ioctl()s, the driver also provides a read/write interface to a BMC ram + region where the host LPC read/write region can be buffered. source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 7a3ea89339b4..4fb10af2ea1c 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -37,7 +37,6 @@ obj-y += eeprom/ obj-y += cb710/ obj-$(CONFIG_SPEAR13XX_PCIE_GADGET) += spear13xx_pcie_gadget.o obj-$(CONFIG_VMWARE_BALLOON) += vmw_balloon.o -obj-$(CONFIG_ARM_CHARLCD) += arm-charlcd.o obj-$(CONFIG_PCH_PHUB) += pch_phub.o obj-y += ti-st/ obj-y += lis3lv02d/ @@ -53,7 +52,7 @@ obj-$(CONFIG_GENWQE) += genwqe/ obj-$(CONFIG_ECHO) += echo/ obj-$(CONFIG_VEXPRESS_SYSCFG) += vexpress-syscfg.o obj-$(CONFIG_CXL_BASE) += cxl/ -obj-$(CONFIG_PANEL) += panel.o +obj-$(CONFIG_ASPEED_LPC_CTRL) += aspeed-lpc-ctrl.o lkdtm-$(CONFIG_LKDTM) += lkdtm_core.o lkdtm-$(CONFIG_LKDTM) += lkdtm_bugs.o @@ -62,6 +61,8 @@ lkdtm-$(CONFIG_LKDTM) += lkdtm_perms.o lkdtm-$(CONFIG_LKDTM) += lkdtm_rodata_objcopy.o lkdtm-$(CONFIG_LKDTM) += lkdtm_usercopy.o +KCOV_INSTRUMENT_lkdtm_rodata.o := n + OBJCOPYFLAGS := OBJCOPYFLAGS_lkdtm_rodata_objcopy.o := \ --set-section-flags .text=alloc,readonly \ diff --git a/drivers/misc/arm-charlcd.c b/drivers/misc/arm-charlcd.c deleted file mode 100644 index b3176ee92b90..000000000000 --- a/drivers/misc/arm-charlcd.c +++ /dev/null @@ -1,368 +0,0 @@ -/* - * Driver for the on-board character LCD found on some ARM reference boards - * This is basically an Hitachi HD44780 LCD with a custom IP block to drive it - * http://en.wikipedia.org/wiki/HD44780_Character_LCD - * Currently it will just display the text "ARM Linux" and the linux version - * - * License terms: GNU General Public License (GPL) version 2 - * Author: Linus Walleij <triad@df.lth.se> - */ -#include <linux/init.h> -#include <linux/interrupt.h> -#include <linux/platform_device.h> -#include <linux/of.h> -#include <linux/completion.h> -#include <linux/delay.h> -#include <linux/io.h> -#include <linux/slab.h> -#include <linux/workqueue.h> -#include <generated/utsrelease.h> - -#define DRIVERNAME "arm-charlcd" -#define CHARLCD_TIMEOUT (msecs_to_jiffies(1000)) - -/* Offsets to registers */ -#define CHAR_COM 0x00U -#define CHAR_DAT 0x04U -#define CHAR_RD 0x08U -#define CHAR_RAW 0x0CU -#define CHAR_MASK 0x10U -#define CHAR_STAT 0x14U - -#define CHAR_RAW_CLEAR 0x00000000U -#define CHAR_RAW_VALID 0x00000100U - -/* Hitachi HD44780 display commands */ -#define HD_CLEAR 0x01U -#define HD_HOME 0x02U -#define HD_ENTRYMODE 0x04U -#define HD_ENTRYMODE_INCREMENT 0x02U -#define HD_ENTRYMODE_SHIFT 0x01U -#define HD_DISPCTRL 0x08U -#define HD_DISPCTRL_ON 0x04U -#define HD_DISPCTRL_CURSOR_ON 0x02U -#define HD_DISPCTRL_CURSOR_BLINK 0x01U -#define HD_CRSR_SHIFT 0x10U -#define HD_CRSR_SHIFT_DISPLAY 0x08U -#define HD_CRSR_SHIFT_DISPLAY_RIGHT 0x04U -#define HD_FUNCSET 0x20U -#define HD_FUNCSET_8BIT 0x10U -#define HD_FUNCSET_2_LINES 0x08U -#define HD_FUNCSET_FONT_5X10 0x04U -#define HD_SET_CGRAM 0x40U -#define HD_SET_DDRAM 0x80U -#define HD_BUSY_FLAG 0x80U - -/** - * @dev: a pointer back to containing device - * @phybase: the offset to the controller in physical memory - * @physize: the size of the physical page - * @virtbase: the offset to the controller in virtual memory - * @irq: reserved interrupt number - * @complete: completion structure for the last LCD command - */ -struct charlcd { - struct device *dev; - u32 phybase; - u32 physize; - void __iomem *virtbase; - int irq; - struct completion complete; - struct delayed_work init_work; -}; - -static irqreturn_t charlcd_interrupt(int irq, void *data) -{ - struct charlcd *lcd = data; - u8 status; - - status = readl(lcd->virtbase + CHAR_STAT) & 0x01; - /* Clear IRQ */ - writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW); - if (status) - complete(&lcd->complete); - else - dev_info(lcd->dev, "Spurious IRQ (%02x)\n", status); - return IRQ_HANDLED; -} - - -static void charlcd_wait_complete_irq(struct charlcd *lcd) -{ - int ret; - - ret = wait_for_completion_interruptible_timeout(&lcd->complete, - CHARLCD_TIMEOUT); - /* Disable IRQ after completion */ - writel(0x00, lcd->virtbase + CHAR_MASK); - - if (ret < 0) { - dev_err(lcd->dev, - "wait_for_completion_interruptible_timeout() " - "returned %d waiting for ready\n", ret); - return; - } - - if (ret == 0) { - dev_err(lcd->dev, "charlcd controller timed out " - "waiting for ready\n"); - return; - } -} - -static u8 charlcd_4bit_read_char(struct charlcd *lcd) -{ - u8 data; - u32 val; - int i; - - /* If we can, use an IRQ to wait for the data, else poll */ - if (lcd->irq >= 0) - charlcd_wait_complete_irq(lcd); - else { - i = 0; - val = 0; - while (!(val & CHAR_RAW_VALID) && i < 10) { - udelay(100); - val = readl(lcd->virtbase + CHAR_RAW); - i++; - } - - writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW); - } - msleep(1); - - /* Read the 4 high bits of the data */ - data = readl(lcd->virtbase + CHAR_RD) & 0xf0; - - /* - * The second read for the low bits does not trigger an IRQ - * so in this case we have to poll for the 4 lower bits - */ - i = 0; - val = 0; - while (!(val & CHAR_RAW_VALID) && i < 10) { - udelay(100); - val = readl(lcd->virtbase + CHAR_RAW); - i++; - } - writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW); - msleep(1); - - /* Read the 4 low bits of the data */ - data |= (readl(lcd->virtbase + CHAR_RD) >> 4) & 0x0f; - - return data; -} - -static bool charlcd_4bit_read_bf(struct charlcd *lcd) -{ - if (lcd->irq >= 0) { - /* - * If we'll use IRQs to wait for the busyflag, clear any - * pending flag and enable IRQ - */ - writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW); - init_completion(&lcd->complete); - writel(0x01, lcd->virtbase + CHAR_MASK); - } - readl(lcd->virtbase + CHAR_COM); - return charlcd_4bit_read_char(lcd) & HD_BUSY_FLAG ? true : false; -} - -static void charlcd_4bit_wait_busy(struct charlcd *lcd) -{ - int retries = 50; - - udelay(100); - while (charlcd_4bit_read_bf(lcd) && retries) - retries--; - if (!retries) - dev_err(lcd->dev, "timeout waiting for busyflag\n"); -} - -static void charlcd_4bit_command(struct charlcd *lcd, u8 cmd) -{ - u32 cmdlo = (cmd << 4) & 0xf0; - u32 cmdhi = (cmd & 0xf0); - - writel(cmdhi, lcd->virtbase + CHAR_COM); - udelay(10); - writel(cmdlo, lcd->virtbase + CHAR_COM); - charlcd_4bit_wait_busy(lcd); -} - -static void charlcd_4bit_char(struct charlcd *lcd, u8 ch) -{ - u32 chlo = (ch << 4) & 0xf0; - u32 chhi = (ch & 0xf0); - - writel(chhi, lcd->virtbase + CHAR_DAT); - udelay(10); - writel(chlo, lcd->virtbase + CHAR_DAT); - charlcd_4bit_wait_busy(lcd); -} - -static void charlcd_4bit_print(struct charlcd *lcd, int line, const char *str) -{ - u8 offset; - int i; - - /* - * We support line 0, 1 - * Line 1 runs from 0x00..0x27 - * Line 2 runs from 0x28..0x4f - */ - if (line == 0) - offset = 0; - else if (line == 1) - offset = 0x28; - else - return; - - /* Set offset */ - charlcd_4bit_command(lcd, HD_SET_DDRAM | offset); - - /* Send string */ - for (i = 0; i < strlen(str) && i < 0x28; i++) - charlcd_4bit_char(lcd, str[i]); -} - -static void charlcd_4bit_init(struct charlcd *lcd) -{ - /* These commands cannot be checked with the busy flag */ - writel(HD_FUNCSET | HD_FUNCSET_8BIT, lcd->virtbase + CHAR_COM); - msleep(5); - writel(HD_FUNCSET | HD_FUNCSET_8BIT, lcd->virtbase + CHAR_COM); - udelay(100); - writel(HD_FUNCSET | HD_FUNCSET_8BIT, lcd->virtbase + CHAR_COM); - udelay(100); - /* Go to 4bit mode */ - writel(HD_FUNCSET, lcd->virtbase + CHAR_COM); - udelay(100); - /* - * 4bit mode, 2 lines, 5x8 font, after this the number of lines - * and the font cannot be changed until the next initialization sequence - */ - charlcd_4bit_command(lcd, HD_FUNCSET | HD_FUNCSET_2_LINES); - charlcd_4bit_command(lcd, HD_DISPCTRL | HD_DISPCTRL_ON); - charlcd_4bit_command(lcd, HD_ENTRYMODE | HD_ENTRYMODE_INCREMENT); - charlcd_4bit_command(lcd, HD_CLEAR); - charlcd_4bit_command(lcd, HD_HOME); - /* Put something useful in the display */ - charlcd_4bit_print(lcd, 0, "ARM Linux"); - charlcd_4bit_print(lcd, 1, UTS_RELEASE); -} - -static void charlcd_init_work(struct work_struct *work) -{ - struct charlcd *lcd = - container_of(work, struct charlcd, init_work.work); - - charlcd_4bit_init(lcd); -} - -static int __init charlcd_probe(struct platform_device *pdev) -{ - int ret; - struct charlcd *lcd; - struct resource *res; - - lcd = kzalloc(sizeof(struct charlcd), GFP_KERNEL); - if (!lcd) - return -ENOMEM; - - lcd->dev = &pdev->dev; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - ret = -ENOENT; - goto out_no_resource; - } - lcd->phybase = res->start; - lcd->physize = resource_size(res); - - if (request_mem_region(lcd->phybase, lcd->physize, - DRIVERNAME) == NULL) { - ret = -EBUSY; - goto out_no_memregion; - } - - lcd->virtbase = ioremap(lcd->phybase, lcd->physize); - if (!lcd->virtbase) { - ret = -ENOMEM; - goto out_no_memregion; - } - - lcd->irq = platform_get_irq(pdev, 0); - /* If no IRQ is supplied, we'll survive without it */ - if (lcd->irq >= 0) { - if (request_irq(lcd->irq, charlcd_interrupt, 0, - DRIVERNAME, lcd)) { - ret = -EIO; - goto out_no_irq; - } - } - - platform_set_drvdata(pdev, lcd); - - /* - * Initialize the display in a delayed work, because - * it is VERY slow and would slow down the boot of the system. - */ - INIT_DELAYED_WORK(&lcd->init_work, charlcd_init_work); - schedule_delayed_work(&lcd->init_work, 0); - - dev_info(&pdev->dev, "initialized ARM character LCD at %08x\n", - lcd->phybase); - - return 0; - -out_no_irq: - iounmap(lcd->virtbase); -out_no_memregion: - release_mem_region(lcd->phybase, SZ_4K); -out_no_resource: - kfree(lcd); - return ret; -} - -static int charlcd_suspend(struct device *dev) -{ - struct platform_device *pdev = to_platform_device(dev); - struct charlcd *lcd = platform_get_drvdata(pdev); - - /* Power the display off */ - charlcd_4bit_command(lcd, HD_DISPCTRL); - return 0; -} - -static int charlcd_resume(struct device *dev) -{ - struct platform_device *pdev = to_platform_device(dev); - struct charlcd *lcd = platform_get_drvdata(pdev); - - /* Turn the display back on */ - charlcd_4bit_command(lcd, HD_DISPCTRL | HD_DISPCTRL_ON); - return 0; -} - -static const struct dev_pm_ops charlcd_pm_ops = { - .suspend = charlcd_suspend, - .resume = charlcd_resume, -}; - -static const struct of_device_id charlcd_match[] = { - { .compatible = "arm,versatile-lcd", }, - {} -}; - -static struct platform_driver charlcd_driver = { - .driver = { - .name = DRIVERNAME, - .pm = &charlcd_pm_ops, - .suppress_bind_attrs = true, - .of_match_table = of_match_ptr(charlcd_match), - }, -}; -builtin_platform_driver_probe(charlcd_driver, charlcd_probe); diff --git a/drivers/misc/aspeed-lpc-ctrl.c b/drivers/misc/aspeed-lpc-ctrl.c new file mode 100644 index 000000000000..b5439643f54b --- /dev/null +++ b/drivers/misc/aspeed-lpc-ctrl.c @@ -0,0 +1,266 @@ +/* + * Copyright 2017 IBM Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ + +#include <linux/mfd/syscon.h> +#include <linux/miscdevice.h> +#include <linux/mm.h> +#include <linux/module.h> +#include <linux/of_address.h> +#include <linux/platform_device.h> +#include <linux/poll.h> +#include <linux/regmap.h> + +#include <linux/aspeed-lpc-ctrl.h> + +#define DEVICE_NAME "aspeed-lpc-ctrl" + +#define HICR7 0x8 +#define HICR8 0xc + +struct aspeed_lpc_ctrl { + struct miscdevice miscdev; + struct regmap *regmap; + phys_addr_t mem_base; + resource_size_t mem_size; + u32 pnor_size; + u32 pnor_base; +}; + +static struct aspeed_lpc_ctrl *file_aspeed_lpc_ctrl(struct file *file) +{ + return container_of(file->private_data, struct aspeed_lpc_ctrl, + miscdev); +} + +static int aspeed_lpc_ctrl_mmap(struct file *file, struct vm_area_struct *vma) +{ + struct aspeed_lpc_ctrl *lpc_ctrl = file_aspeed_lpc_ctrl(file); + unsigned long vsize = vma->vm_end - vma->vm_start; + pgprot_t prot = vma->vm_page_prot; + + if (vma->vm_pgoff + vsize > lpc_ctrl->mem_base + lpc_ctrl->mem_size) + return -EINVAL; + + /* ast2400/2500 AHB accesses are not cache coherent */ + prot = pgprot_noncached(prot); + + if (remap_pfn_range(vma, vma->vm_start, + (lpc_ctrl->mem_base >> PAGE_SHIFT) + vma->vm_pgoff, + vsize, prot)) + return -EAGAIN; + + return 0; +} + +static long aspeed_lpc_ctrl_ioctl(struct file *file, unsigned int cmd, + unsigned long param) +{ + struct aspeed_lpc_ctrl *lpc_ctrl = file_aspeed_lpc_ctrl(file); + void __user *p = (void __user *)param; + struct aspeed_lpc_ctrl_mapping map; + u32 addr; + u32 size; + long rc; + + if (copy_from_user(&map, p, sizeof(map))) + return -EFAULT; + + if (map.flags != 0) + return -EINVAL; + + switch (cmd) { + case ASPEED_LPC_CTRL_IOCTL_GET_SIZE: + /* The flash windows don't report their size */ + if (map.window_type != ASPEED_LPC_CTRL_WINDOW_MEMORY) + return -EINVAL; + + /* Support more than one window id in the future */ + if (map.window_id != 0) + return -EINVAL; + + map.size = lpc_ctrl->mem_size; + + return copy_to_user(p, &map, sizeof(map)) ? -EFAULT : 0; + case ASPEED_LPC_CTRL_IOCTL_MAP: + + /* + * The top half of HICR7 is the MSB of the BMC address of the + * mapping. + * The bottom half of HICR7 is the MSB of the HOST LPC + * firmware space address of the mapping. + * + * The 1 bits in the top of half of HICR8 represent the bits + * (in the requested address) that should be ignored and + * replaced with those from the top half of HICR7. + * The 1 bits in the bottom half of HICR8 represent the bits + * (in the requested address) that should be kept and pass + * into the BMC address space. + */ + + /* + * It doesn't make sense to talk about a size or offset with + * low 16 bits set. Both HICR7 and HICR8 talk about the top 16 + * bits of addresses and sizes. + */ + + if ((map.size & 0x0000ffff) || (map.offset & 0x0000ffff)) + return -EINVAL; + + /* + * Because of the way the masks work in HICR8 offset has to + * be a multiple of size. + */ + if (map.offset & (map.size - 1)) + return -EINVAL; + + if (map.window_type == ASPEED_LPC_CTRL_WINDOW_FLASH) { + addr = lpc_ctrl->pnor_base; + size = lpc_ctrl->pnor_size; + } else if (map.window_type == ASPEED_LPC_CTRL_WINDOW_MEMORY) { + addr = lpc_ctrl->mem_base; + size = lpc_ctrl->mem_size; + } else { + return -EINVAL; + } + + /* Check overflow first! */ + if (map.offset + map.size < map.offset || + map.offset + map.size > size) + return -EINVAL; + + if (map.size == 0 || map.size > size) + return -EINVAL; + + addr += map.offset; + + /* + * addr (host lpc address) is safe regardless of values. This + * simply changes the address the host has to request on its + * side of the LPC bus. This cannot impact the hosts own + * memory space by surprise as LPC specific accessors are + * required. The only strange thing that cou |