x86: dm: Convert x86 to use driver model more fully
Subsystems (9)
cover x86: dm: Convert x86 to use driver model more fully
At present x86 does not use driver model for SPI or LPC (low-pin-count, a bus used to talk to the EC on Chromebooks).
This series:
- moves the ICH SPI driver over to driver model
- moves the cros_ec LPC driver to driver model
- removes non-driver-model cros_ec code (since now I2C, SPI and LPC are converted over)
- makes some use of the PCI uclass for x86 init, by no means complete
- fixes up the keyboard to work on chromebook_link (previously it would only work when started from coreboot)
Simon Glass (16):
dm: sf: Add driver model read/write/erase methods
dm: x86: spi: Convert ICH SPI driver to driver model
dm: x86: Add a uclass for a Platform Controller Hub
dm: x86: Add a uclass for an Low Pin Count (LPC) device
x86: chromebook_link: dts: Add PCH and LPC devices
dm: cros_ec: Convert cros_ec LPC driver to driver model
cros_ec: Reinit the cros_ec device when 'crosec init' is used
cros_ec: Drop unused CONFIG_DM_CROS_EC
sandbox: cros_ec: Drop unnecessary init
x86: cros_ec: Drop unnecessary init
exynos: cros_ec: Drop unnecessary init
cros_ec: Remove unused cros_ec_board_init() function
fdt: cros_ec: Drop compatible string in fdtdec
fdt: Drop LPC compatible string in fdtdec
cros_ec: exynos: Match up device tree with kernel version
i8042: Add keyboard enable logic in kbd_reset()
README | 8 - arch/arm/dts/exynos5250-snow.dts | 7 +- arch/arm/dts/exynos5420-peach-pit.dts | 5 +- arch/arm/dts/exynos5800-peach-pi.dts | 4 +- arch/sandbox/Kconfig | 3 - arch/sandbox/dts/cros-ec-keyboard.dtsi | 105 +++++ arch/sandbox/dts/sandbox.dts | 115 ++---- arch/x86/Kconfig | 6 + arch/x86/cpu/ivybridge/bd82x6x.c | 9 - arch/x86/cpu/ivybridge/cpu.c | 2 +- arch/x86/cpu/ivybridge/lpc.c | 13 +- arch/x86/cpu/ivybridge/mrccache.c | 7 +- arch/x86/cpu/ivybridge/sdram.c | 17 +- arch/x86/dts/chromebook_link.dts | 70 ++-- arch/x86/include/asm/arch-ivybridge/mrccache.h | 4 +- arch/x86/lib/Makefile | 2 + arch/x86/lib/init_helpers.c | 8 - arch/x86/lib/lpc-uclass.c | 28 ++ arch/x86/lib/pch-uclass.c | 28 ++ board/coreboot/coreboot/coreboot.c | 5 - board/google/chromebook_link/link.c | 3 - board/samsung/common/board.c | 12 - board/samsung/smdk5420/Kconfig | 6 - board/sandbox/sandbox.c | 12 - common/board_r.c | 3 - common/cros_ec.c | 33 -- drivers/input/cros_ec_keyb.c | 2 +- drivers/input/i8042.c | 7 + drivers/misc/Kconfig | 9 - drivers/misc/cros_ec.c | 250 +----------- drivers/misc/cros_ec_i2c.c | 4 +- drivers/misc/cros_ec_lpc.c | 29 +- drivers/misc/cros_ec_sandbox.c | 77 +--- drivers/misc/cros_ec_spi.c | 4 +- drivers/mtd/spi/sf-uclass.c | 16 + drivers/spi/ich.c | 519 +++++++++++++------------ include/configs/exynos5420-common.h | 2 - include/configs/sandbox.h | 1 - include/configs/snow.h | 2 - include/configs/x86-common.h | 1 - include/cros_ec.h | 137 ------- include/dm/uclass-id.h | 1 + include/fdtdec.h | 4 +- include/spi_flash.h | 47 ++- lib/fdtdec.c | 4 +- 45 files changed, 649 insertions(+), 982 deletions(-) create mode 100644 arch/sandbox/dts/cros-ec-keyboard.dtsi create mode 100644 arch/x86/lib/lpc-uclass.c create mode 100644 arch/x86/lib/pch-uclass.c
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 1/16 dm: sf: Add driver model read/write/erase methods
Permit use of a udevice to talk to SPI flash. Ultimately we would like to retire the use of 'struct spi_flash' for this purpose, so create the new API for those who want to move to it.
---
drivers/mtd/spi/sf-uclass.c | 16 +++++++++++++++ include/spi_flash.h | 47 +++++++++++++++++++++++++++++++++++++++------ 2 files changed, 57 insertions(+), 6 deletions(-)
drivers/mtd/spi/sf-uclass.c +16 -0
@@ -11,6 +11,22 @@#include <dm/device-internal.h> #include "sf_internal.h" +int spi_flash_read_dm (struct udevice *dev,u32 offset,size_t len,void *buf) +{ +return sf_get_ops (dev)->read (dev, offset, len, buf); +} + +int spi_flash_write_dm (struct udevice *dev,u32 offset,size_t len, +const void *buf) +{ +return sf_get_ops (dev)->write (dev, offset, len, buf); +} + +int spi_flash_erase_dm (struct udevice *dev,u32 offset,size_t len) +{ +return sf_get_ops (dev)->erase (dev, offset, len); +} +/* * TODO(sjg at chromium.org): This is an old-style function. We should remove * it when all SPI flash drivers use dm
include/spi_flash.h +41 -6
68 lines not on this page · raw message
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 2/16 dm: x86: spi: Convert ICH SPI driver to driver model
In reply to Simon GlassConvert this driver over to use driver model. Since all x86 platforms use it, move x86 to use driver model for SPI and SPI flash. Adjust all dependent code and remove the old x86 spi_init() function.
Note that this does not make full use of the new PCI uclass as yet. We still scan the bus looking for the device. It should move to finding its details in the device tree.
---
arch/x86/Kconfig | 6 + arch/x86/cpu/ivybridge/mrccache.c | 7 +- arch/x86/cpu/ivybridge/sdram.c | 17 +- arch/x86/include/asm/arch-ivybridge/mrccache.h | 4 +- arch/x86/lib/init_helpers.c | 8 - common/board_r.c | 3 - drivers/spi/ich.c | 519 +++++++++++++------------ include/configs/x86-common.h | 1 - 8 files changed, 287 insertions(+), 278 deletions(-)
arch/x86/Kconfig +6 -0
@@ -90,6 +90,12 @@ config DM_GPIO config DM_SERIAL default y +config DM_SPI + default y + +config DM_SPI_FLASH + default y + config SYS_MALLOC_F default y
arch/x86/cpu/ivybridge/mrccache.c +4 -3
@@ -105,7 +105,7 @@ static struct mrc_data_container *find_next_mrc_cache(struct fmap_entry *entry,return cache; } -int mrccache_update (struct spi_flash *sf,struct fmap_entry *entry, +int mrccache_update (struct udevice *sf,struct fmap_entry *entry,struct mrc_data_container *cur) {struct mrc_data_container *cache;
@@ -135,7 +135,7 @@ int mrccache_update(struct spi_flash *sf, struct fmap_entry *entry,debug ("Erasing the MRC cache region of %x bytes at %x\n" , entry->length, entry->offset); - ret =spi_flash_erase (sf, entry->offset, entry->length); + ret =spi_flash_erase_dm (sf, entry->offset, entry->length);if (ret) {debug ("Failed to erase flash region\n" );return ret;
@@ -146,7 +146,8 @@ int mrccache_update(struct spi_flash *sf, struct fmap_entry *entry,/* Write the data out */ offset = (ulong )cache - base_addr + entry->offset;debug ("Write MRC cache update to flash at %lx\n" , offset); - ret =spi_flash_write (sf, offset, cur->data_size +sizeof (*cur), cur); + ret =spi_flash_write_dm (sf, offset, cur->data_size +sizeof (*cur), + cur);if (ret) {debug ("Failed to write to SPI flash\n" );return ret;
arch/x86/cpu/ivybridge/sdram.c +10 -7
@@ -89,11 +89,12 @@ void dram_init_banksize(void) } } -static int get_mrc_entry (struct spi_flash **sfp,struct fmap_entry *entry) +static int get_mrc_entry (struct udevice **devp,struct fmap_entry *entry) {const void *blob = gd->fdt_blob;int node, spi_node, mrc_node;int upto; +int ret;/* Find the flash chip within the SPI controller node */ upto =0 ;
@@ -112,10 +113,13 @@ static int get_mrc_entry(struct spi_flash **sfp, struct fmap_entry *entry)if (fdtdec_read_fmap_entry (blob, mrc_node,"rm-mrc-cache" , entry))return -EINVAL ; -if (sfp) { - *sfp =spi_flash_probe_fdt (blob, node, spi_node); -if (!*sfp) -return -EBADF ; +if (devp) { +debug ("getting sf\n" ); + ret =uclass_get_device_by_of_offset (UCLASS_SPI_FLASH , node, + devp); +debug ("ret = %d\n" , ret); +if (ret) +return ret; }return 0 ;
@@ -246,7 +250,7 @@ static int sdram_save_mrc_data(void) {struct mrc_data_container *data;struct fmap_entry entry; -struct spi_flash *sf; +struct udevice *sf;int ret;if (!gd->arch.mrc_output_len)
@@ -266,7 +270,6 @@ static int sdram_save_mrc_data(void)free (data); err_data: -spi_flash_free (sf); err_entry:if (ret)debug ("%s: Failed: %d\n" , __func__, ret);
arch/x86/include/asm/arch-ivybridge/mrccache.h +2 -2
@@ -20,7 +20,7 @@ __packed struct mrc_data_container { };struct fmap_entry ; -struct spi_flash ; +struct udevice ;/** * mrccache_find_current() - find the latest MRC cache record
@@ -45,7 +45,7 @@ struct mrc_data_container *mrccache_find_current(struct fmap_entry *entry);* @return 0 if updated, -EEXIST if the record is the same as the latest * record, other error if SPI write failed */ -int mrccache_update (struct spi_flash *sf,struct fmap_entry *entry, +int mrccache_update (struct udevice *sf,struct fmap_entry *entry,struct mrc_data_container *cur);#endif
arch/x86/lib/init_helpers.c +0 -8
@@ -89,11 +89,3 @@ int init_bd_struct_r(void)return 0 ; } - -int init_func_spi (void ) -{ -puts ("SPI: " ); -spi_init (); -puts ("ready\n" ); -return 0 ; -}
common/board_r.c +0 -3
@@ -761,9 +761,6 @@ init_fnc_t init_sequence_r[] = {#ifdef CONFIG_PPC initr_spi,#endif -#if defined(CONFIG_X86 ) && defined(CONFIG_SPI ) - init_func_spi, -#endif #ifdef CONFIG_CMD_NAND initr_nand,#endif
drivers/spi/ich.c +265 -254
832 lines not on this page · raw message
include/configs/x86-common.h +0 -1
@@ -204,7 +204,6 @@#define CONFIG_CMD_SF_TEST #define CONFIG_CMD_SPI #define CONFIG_SPI -#define CONFIG_OF_SPI_FLASH /*----------------------------------------------------------------------- * Environment configuration
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 3/16 dm: x86: Add a uclass for a Platform Controller Hub
In reply to Simon GlassAdd a simple uclass for this chip which is often found in x86 systems where the CPU is a separate device.
The device can have children, so make it scan the device tree for these.
---
arch/x86/cpu/ivybridge/bd82x6x.c | 9 --------- arch/x86/lib/Makefile | 1 + arch/x86/lib/pch-uclass.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 arch/x86/lib/pch-uclass.c
arch/x86/cpu/ivybridge/bd82x6x.c +0 -9
@@ -157,12 +157,3 @@ U_BOOT_DRIVER(bd82x6x_drv) = { .of_match = bd82x6x_ids, .probe = bd82x6x_probe, }; - -/* -* TODO(sjg at chromium.org): Move this to arch/x86/lib or similar when other -* boards also use a PCH -*/ -UCLASS_DRIVER (pch) = { - .id =UCLASS_PCH , - .name ="pch" , -};
arch/x86/lib/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_SYS_PCAT_TIMER) += pcat_timer.o ifndef CONFIG_DM_PCI obj-$(CONFIG_PCI) += pci_type1.o endif +obj-y += pch-uclass.o obj-y += relocate.o obj-y += physmem.o obj-$(CONFIG_X86_RAMTEST) += ramtest.o
arch/x86/lib/pch-uclass.c new file +28 -0
@@ -0,0 +1,28 @@ +/* +* Copyright (c) 2015 Google, Inc +* Written by Simon Glass <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <dm.h> +#include <dm/root.h> + +static int pch_uclass_post_bind (struct udevice *bus) +{ +/* +* Scan the device tree for devices +* +* Before relocation, only bind devices marked for pre-relocation +* use. +*/ +return dm_scan_fdt_node (bus, gd->fdt_blob, bus->of_offset, + gd->flags &GD_FLG_RELOC ? false : true); +} + +UCLASS_DRIVER (pch) = { + .id =UCLASS_PCH , + .name ="pch" , + .post_bind = pch_uclass_post_bind, +};
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 4/16 dm: x86: Add a uclass for an Low Pin Count (LPC) device
In reply to Simon GlassOn x86 systems this device is commonly used to provide legacy port access. It is sort-of a replacement for the old ISA bus.
Add a uclass for this, and allow it to have child devices.
---
arch/x86/lib/Makefile | 1 + arch/x86/lib/lpc-uclass.c | 28 ++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + 3 files changed, 30 insertions(+) create mode 100644 arch/x86/lib/lpc-uclass.c
arch/x86/lib/Makefile +1 -0
@@ -14,6 +14,7 @@ obj-$(CONFIG_HAVE_FSP) += cmd_hob.o obj-y += gcc.o obj-y += init_helpers.o obj-y += interrupts.o +obj-y += lpc-uclass.o obj-y += cmd_mtrr.o obj-$(CONFIG_SYS_PCAT_INTERRUPTS) += pcat_interrupts.o obj-$(CONFIG_SYS_PCAT_TIMER) += pcat_timer.o
arch/x86/lib/lpc-uclass.c new file +28 -0
@@ -0,0 +1,28 @@ +/* +* Copyright (c) 2015 Google, Inc +* Written by Simon Glass <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <dm.h> +#include <dm/root.h> + +static int lpc_uclass_post_bind (struct udevice *bus) +{ +/* +* Scan the device tree for devices +* +* Before relocation, only bind devices marked for pre-relocation +* use. +*/ +return dm_scan_fdt_node (bus, gd->fdt_blob, bus->of_offset, + gd->flags &GD_FLG_RELOC ? false : true); +} + +UCLASS_DRIVER (lpc) = { + .id =UCLASS_LPC , + .name ="lpc" , + .post_bind = lpc_uclass_post_bind, +};
include/dm/uclass-id.h +1 -0
@@ -38,6 +38,7 @@ enum uclass_id {UCLASS_PCI ,/* PCI bus */ UCLASS_PCI_GENERIC ,/* Generic PCI bus device */ UCLASS_PCH ,/* x86 platform controller hub */ +UCLASS_LPC ,/* x86 'low pin count' interface */ UCLASS_COUNT , UCLASS_INVALID = -1,
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 5/16 x86: chromebook_link: dts: Add PCH and LPC devices
In reply to Simon GlassThe PCH (Platform Controller Hub) is on the PCI bus, so show it as such. The LPC (Low Pin Count) and SPI bus are inside the PCH, so put these in the right place also.
Rename the compatible strings to be more descriptive since this board is the only user. Once we are using driver model fully on x86, these will be dropped.
---
arch/x86/cpu/ivybridge/cpu.c | 2 +- arch/x86/cpu/ivybridge/lpc.c | 13 +++++++- arch/x86/dts/chromebook_link.dts | 70 ++++++++++++++++++++++------------------ include/fdtdec.h | 1 + lib/fdtdec.c | 3 +- 5 files changed, 55 insertions(+), 34 deletions(-)
arch/x86/cpu/ivybridge/cpu.c +1 -1
@@ -142,7 +142,7 @@ int x86_post_cpu_init(void)/* TODO(sjg at chromium.org): Get rid of gd->hose */ gd->hose = hose; - node =fdtdec_next_compatible (blob,0 ,COMPAT_INTEL_LPC ); + node =fdtdec_next_compatible (blob,0 ,COMPAT_INTEL_PCH );if (node <0 )return -ENOENT ; ret =lpc_early_init (gd->fdt_blob, node,PCH_LPC_DEV );
arch/x86/cpu/ivybridge/lpc.c +12 -1
@@ -510,7 +510,7 @@ int lpc_init(struct pci_controller *hose, pci_dev_t dev)pci_write_bar32 (hose, dev,3 ,0x800 );pci_write_bar32 (hose, dev,4 ,0x900 ); - node =fdtdec_next_compatible (blob,0 ,COMPAT_INTEL_LPC ); + node =fdtdec_next_compatible (blob,0 ,COMPAT_INTEL_PCH );if (node <0 )return -ENOENT ;
@@ -568,3 +568,14 @@ void lpc_enable(pci_dev_t dev)writew (0x0010 ,RCB_REG (DISPBDF ));setbits_le32 (RCB_REG (FD2 ),PCH_ENABLE_DBDF ); } + +static const struct udevice_id bd82x6x_lpc_ids[] = { + { .compatible ="intel,bd82x6x-lpc" }, + { } +}; + +U_BOOT_DRIVER (bd82x6x_lpc_drv) = { + .name ="lpc" , + .id =UCLASS_LPC , + .of_match = bd82x6x_lpc_ids, +};
arch/x86/dts/chromebook_link.dts +39 -31
98 lines not on this page · raw message
include/fdtdec.h +1 -0
@@ -168,6 +168,7 @@ enum fdt_compat_id {COMPAT_AMS_AS3722 ,/* AMS AS3722 PMIC */ COMPAT_INTEL_ICH_SPI ,/* Intel ICH7/9 SPI controller */ COMPAT_INTEL_QRK_MRC ,/* Intel Quark MRC */ +COMPAT_INTEL_PCH ,/* Intel PCH */ COMPAT_COUNT, };
lib/fdtdec.c +2 -1
@@ -67,7 +67,7 @@ static const char * const compat_names[COMPAT_COUNT] = {COMPAT (COMPAT_NXP_PTN3460 ,"nxp,ptn3460" ),COMPAT (SAMSUNG_EXYNOS_SYSMMU ,"samsung,sysmmu-v3.3" ),COMPAT (PARADE_PS8625 ,"parade,ps8625" ), -COMPAT (COMPAT_INTEL_LPC ,"intel,bd82x6x" ), +COMPAT (COMPAT_INTEL_LPC ,"intel,bd82x6x-lpc" ),COMPAT (INTEL_MICROCODE ,"intel,microcode" ),COMPAT (MEMORY_SPD ,"memory-spd" ), COMPAT(INTEL_PANTHERPOINT_AHCI, "intel,pantherpoint-ahci"),
@@ -76,6 +76,7 @@ static const char * const compat_names[COMPAT_COUNT] = {COMPAT (AMS_AS3722 ,"ams,as3722" ),COMPAT (INTEL_ICH_SPI ,"intel,ich-spi" ),COMPAT (INTEL_QRK_MRC ,"intel,quark-mrc" ), + COMPAT(COMPAT_INTEL_PCH, "intel,bd82x6x"), };const char *fdtdec_get_compatible (enum fdt_compat_id id)
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 6/16 dm: cros_ec: Convert cros_ec LPC driver to driver model
In reply to Simon GlassThis is the last driver to be converted. It requires an LPC bus and a special check_version() method.
---
configs/chromebook_link_defconfig | 1 + drivers/misc/cros_ec.c | 12 ++++++++++++ drivers/misc/cros_ec_lpc.c | 29 +++++++++++++++++++++++++++-- 3 files changed, 40 insertions(+), 2 deletions(-)
configs/chromebook_link_defconfig +1 -0
@@ -10,3 +10,4 @@ CONFIG_VIDEO_VESA=y CONFIG_FRAMEBUFFER_SET_VESA_MODE=y CONFIG_FRAMEBUFFER_VESA_MODE_11A=y CONFIG_DM_PCI=y +CONFIG_DM_CROS_EC=y
drivers/misc/cros_ec.c +12 -0
@@ -681,11 +681,23 @@ static int cros_ec_check_version(struct cros_ec_dev *dev)struct ec_params_hello req;struct ec_response_hello *resp; +#ifdef CONFIG_DM_CROS_EC +struct dm_cros_ec_ops *ops; +int ret; + + ops =dm_cros_ec_get_ops (dev->dev); +if (ops->check_version) { + ret = ops->check_version (dev->dev); +if (ret) +return ret; + } +#else #ifdef CONFIG_CROS_EC_LPC /* LPC has its own way of doing this */ if (dev->interface ==CROS_EC_IF_LPC )return cros_ec_lpc_check_version (dev);#endif +#endif /* * TODO(sjg at chromium.org).
drivers/misc/cros_ec_lpc.c +27 -2
@@ -14,6 +14,7 @@*/ #include <common.h> +#include <dm.h> #include <command.h> #include <cros_ec.h> #include <asm/io.h>
@@ -40,10 +41,11 @@ static int wait_for_sync(struct cros_ec_dev *dev)return 0 ; } -int cros_ec_lpc_command (struct cros_ec_dev *dev,uint8_t cmd,int cmd_version, +int cros_ec_lpc_command (struct udevice *udev,uint8_t cmd,int cmd_version,const uint8_t *dout,int dout_len,uint8_t **dinp,int din_len) { +struct cros_ec_dev *dev =dev_get_uclass_priv (udev);const int cmd_addr =EC_LPC_ADDR_HOST_CMD ;const int data_addr =EC_LPC_ADDR_HOST_DATA ;const int args_addr =EC_LPC_ADDR_HOST_ARGS ;
@@ -178,7 +180,7 @@ int cros_ec_lpc_init(struct cros_ec_dev *dev, const void *blob)* seeing whether the EC sets the EC_HOST_ARGS_FLAG_FROM_HOST flag * in args when it responds. */ -int cros_ec_lpc_check_version (struct cros_ec_dev *dev) +static int cros_ec_lpc_check_version (struct udevice *dev) {if (inb (EC_LPC_ADDR_MEMMAP +EC_MEMMAP_ID ) =='E' && inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_ID + 1)
@@ -192,3 +194,26 @@ int cros_ec_lpc_check_version(struct cros_ec_dev *dev)printf ("%s: ERROR: old EC interface not supported\n" , __func__);return -1 ; } + +static int cros_ec_probe (struct udevice *dev) +{ +return cros_ec_register (dev); +} + +static struct dm_cros_ec_ops cros_ec_ops = { + .command = cros_ec_lpc_command, + .check_version = cros_ec_lpc_check_version, +}; + +static const struct udevice_id cros_ec_ids[] = { + { .compatible ="google,cros-ec" }, + { } +}; + +U_BOOT_DRIVER (cros_ec_lpc) = { + .name ="cros_ec" , + .id =UCLASS_CROS_EC , + .of_match = cros_ec_ids, + .probe = cros_ec_probe, + .ops = &cros_ec_ops, +};
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 7/16 cros_ec: Reinit the cros_ec device when 'crosec init' is used
In reply to Simon GlassThis command is supposed to reinit the device. At present with driver model is does nothing. Implement this feature.
---
drivers/misc/cros_ec.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/misc/cros_ec.c +8 -2
@@ -1606,13 +1606,19 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) cmd = argv[1 ];if (0 ==strcmp ("init" , cmd)) { -#ifndef CONFIG_DM_CROS_EC +#ifdef CONFIG_DM_CROS_EC +/* Remove any existing device */ + ret =uclass_find_device (UCLASS_CROS_EC ,0 , &udev); +if (!ret) +device_remove (udev); + ret =uclass_get_device (UCLASS_CROS_EC ,0 , &udev); +#else ret =cros_ec_init (gd->fdt_blob, &dev); +#endif if (ret) {printf ("Could not init cros_ec device (err %d)\n" , ret);return 1 ; } -#endif return 0 ; }
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 8/16 cros_ec: Drop unused CONFIG_DM_CROS_EC
In reply to Simon GlassSince all supported boards enable this option now, we can remove it along with the old code.
---
README | 8 -- arch/sandbox/Kconfig | 3 - board/samsung/smdk5420/Kconfig | 6 - common/cros_ec.c | 30 +---- configs/chromebook_link_defconfig | 1 - drivers/misc/Kconfig | 9 -- drivers/misc/cros_ec.c | 240 -------------------------------------- drivers/misc/cros_ec_sandbox.c | 73 ------------ include/configs/snow.h | 1 - include/cros_ec.h | 130 --------------------- 10 files changed, 1 insertion(+), 500 deletions(-)
README +0 -8
@@ -708,14 +708,6 @@ The following options need to be configured: enabled together (it is not possible to use driver model for one and not the other). - CONFIG_DM_CROS_EC - - Enable driver model for the Chrome OS EC interface. This - allows the cros_ec SPI driver to operate with CONFIG_DM_SPI - but otherwise makes few changes. Since cros_ec also supports - I2C and LPC (which don't support driver model yet), a full - conversion is not yet possible. - ** Code size options: The following options are enabled by default except in SPL. Enable them explicitly to get these
arch/sandbox/Kconfig +0 -3
@@ -19,9 +19,6 @@ config DM_GPIO config DM_SERIAL default y -config DM_CROS_EC - default y - config DM_SPI default y
board/samsung/smdk5420/Kconfig +0 -6
@@ -22,9 +22,6 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "peach-pi" -config DM_CROS_EC - default y - endif if TARGET_PEACH_PIT
@@ -38,9 +35,6 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "peach-pit" -config DM_CROS_EC - default y - endif if TARGET_SMDK5420
common/cros_ec.c +1 -29
@@ -15,18 +15,8 @@DECLARE_GLOBAL_DATA_PTR ; -#ifndef CONFIG_DM_CROS_EC -struct local_info { -struct cros_ec_dev *cros_ec_dev;/* Pointer to cros_ec device */ -int cros_ec_err;/* Error for cros_ec, 0 if ok */ -}; - -static struct local_info local; -#endif -struct cros_ec_dev *board_get_cros_ec_dev (void ) { -#ifdef CONFIG_DM_CROS_EC struct udevice *dev;int ret;
@@ -36,30 +26,15 @@ struct cros_ec_dev *board_get_cros_ec_dev(void)return NULL ; }return dev_get_uclass_priv (dev); -#else -return local.cros_ec_dev; -#endif -} - -static int board_init_cros_ec_devices (const void *blob) -{ -#ifndef CONFIG_DM_CROS_EC - local.cros_ec_err =cros_ec_init (blob, &local.cros_ec_dev); -if (local.cros_ec_err) -return -1 ;/* Will report in board_late_init() */ -#endif - -return 0 ; }int cros_ec_board_init (void ) { -return board_init_cros_ec_devices (gd->fdt_blob); +return 0 ; }int cros_ec_get_error (void ) { -#ifdef CONFIG_DM_CROS_EC struct udevice *dev;int ret;
@@ -68,7 +43,4 @@ int cros_ec_get_error(void)return ret;return 0 ; -#else -return local.cros_ec_err; -#endif }
configs/chromebook_link_defconfig +0 -1
@@ -10,4 +10,3 @@ CONFIG_VIDEO_VESA=y CONFIG_FRAMEBUFFER_SET_VESA_MODE=y CONFIG_FRAMEBUFFER_VESA_MODE_11A=y CONFIG_DM_PCI=y -CONFIG_DM_CROS_EC=y
drivers/misc/Kconfig +0 -9
@@ -1,9 +0,0 @@ -config DM_CROS_EC - bool "Enable Driver Model for Chrome OS EC" - depends on DM - help - Enable driver model for the Chrome OS EC interface. This - allows the cros_ec SPI driver to operate with CONFIG_DM_SPI - but otherwise makes few changes. Since cros_ec also supports - I2C and LPC (which don't support driver model yet), a full - conversion is not yet possible.
drivers/misc/cros_ec.c +0 -240
339 lines not on this page · raw message
drivers/misc/cros_ec_sandbox.c +0 -73
107 lines not on this page · raw message
include/configs/snow.h +0 -1
@@ -22,7 +22,6 @@#define CONFIG_CROS_EC_I2C /* Support CROS_EC over I2C */ #define CONFIG_POWER_TPS65090_I2C -#define CONFIG_DM_CROS_EC #define CONFIG_BOARD_COMMON #define CONFIG_ARCH_EARLY_INIT_R
include/cros_ec.h +0 -130
151 lines not on this page · raw message
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 9/16 sandbox: cros_ec: Drop unnecessary init
In reply to Simon GlassSince driver model will probe the EC when it is first used, we do not need to init it explicitly.
---
board/sandbox/sandbox.c | 12 ------------ include/configs/sandbox.h | 1 - 2 files changed, 13 deletions(-)
board/sandbox/sandbox.c +0 -12
@@ -53,18 +53,6 @@ int board_early_init_f(void) }#endif -int arch_early_init_r (void ) -{ -#ifdef CONFIG_CROS_EC -if (cros_ec_board_init ()) { -printf ("%s: Failed to init EC\n" , __func__); -return 0 ; - } -#endif - -return 0 ; -} -#ifdef CONFIG_BOARD_LATE_INIT int board_late_init (void ) {
include/configs/sandbox.h +0 -1
@@ -148,7 +148,6 @@#define CONFIG_CROS_EC #define CONFIG_CMD_CROS_EC #define CONFIG_CROS_EC_SANDBOX -#define CONFIG_ARCH_EARLY_INIT_R #define CONFIG_BOARD_LATE_INIT #define CONFIG_SOUND
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 10/16 x86: cros_ec: Drop unnecessary init
In reply to Simon GlassSince driver model will probe the EC when it is first used, we do not need to init it explicitly.
---
board/coreboot/coreboot/coreboot.c | 5 ----- board/google/chromebook_link/link.c | 3 --- 2 files changed, 8 deletions(-)
board/coreboot/coreboot/coreboot.c +0 -5
@@ -10,11 +10,6 @@int arch_early_init_r (void ) { -#ifdef CONFIG_CROS_EC -if (cros_ec_board_init ()) -return -1 ; -#endif -return 0 ; }
board/google/chromebook_link/link.c +0 -3
@@ -22,9 +22,6 @@ int arch_early_init_r(void)if (ret)return ret; -if (cros_ec_board_init ()) -return -1 ; -return 0 ; }
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 11/16 exynos: cros_ec: Drop unnecessary init
In reply to Simon GlassSince driver model will probe the EC when it is first used, we do not need to init it explicitly.
---
board/samsung/common/board.c | 12 ------------ include/configs/exynos5420-common.h | 2 -- include/configs/snow.h | 1 - 3 files changed, 15 deletions(-)
board/samsung/common/board.c +0 -12
@@ -323,18 +323,6 @@ int board_late_init(void) }#endif -int arch_early_init_r (void ) -{ -#ifdef CONFIG_CROS_EC -if (cros_ec_board_init ()) { -printf ("%s: Failed to init EC\n" , __func__); -return 0 ; - } -#endif - -return 0 ; -} -#ifdef CONFIG_MISC_INIT_R int misc_init_r (void ) {
include/configs/exynos5420-common.h +0 -2
@@ -15,8 +15,6 @@#include <configs/exynos5-common.h> -#define CONFIG_ARCH_EARLY_INIT_R -#define MACH_TYPE_SMDK5420 8002#define CONFIG_MACH_TYPE MACH_TYPE_SMDK5420
include/configs/snow.h +0 -1
@@ -24,7 +24,6 @@#define CONFIG_POWER_TPS65090_I2C #define CONFIG_BOARD_COMMON -#define CONFIG_ARCH_EARLY_INIT_R #define CONFIG_USB_XHCI #define CONFIG_USB_XHCI_EXYNOS
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 12/16 cros_ec: Remove unused cros_ec_board_init() function
In reply to Simon GlassNow that driver model handles cros_ec init, we can drop this special code.
---
common/cros_ec.c | 5 ----- include/cros_ec.h | 7 ------- 2 files changed, 12 deletions(-)
common/cros_ec.c +0 -5
@@ -28,11 +28,6 @@ struct cros_ec_dev *board_get_cros_ec_dev(void)return dev_get_uclass_priv (dev); } -int cros_ec_board_init (void ) -{ -return 0 ; -} -int cros_ec_get_error (void ) {struct udevice *dev;
include/cros_ec.h +0 -7
@@ -363,13 +363,6 @@ int cros_ec_set_ldo(struct cros_ec_dev *dev, uint8_t index, uint8_t state);int cros_ec_get_ldo (struct cros_ec_dev *dev,uint8_t index,uint8_t *state);/** -* Initialize the Chrome OS EC at board initialization time. -* -* @return 0 if ok, -ve on error -*/ -int cros_ec_board_init (void ); - -/** * Get access to the error reported when cros_ec_board_init() was called * * This permits delayed reporting of the EC error if it failed during
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 13/16 fdt: cros_ec: Drop compatible string in fdtdec
In reply to Simon GlassThis is not needed now that we have moved to driver model.
---
include/fdtdec.h | 1 - lib/fdtdec.c | 1 - 2 files changed, 2 deletions(-)
include/fdtdec.h +0 -1
@@ -134,7 +134,6 @@ enum fdt_compat_id {COMPAT_SAMSUNG_S3C2440_I2C ,/* Exynos I2C Controller */ COMPAT_SAMSUNG_EXYNOS5_SOUND ,/* Exynos Sound */ COMPAT_WOLFSON_WM8994_CODEC ,/* Wolfson WM8994 Sound Codec */ -COMPAT_GOOGLE_CROS_EC ,/* Google CROS_EC Protocol */ COMPAT_GOOGLE_CROS_EC_KEYB ,/* Google CROS_EC Keyboard */ COMPAT_SAMSUNG_EXYNOS_EHCI ,/* Exynos EHCI controller */ COMPAT_SAMSUNG_EXYNOS5_XHCI, /* Exynos5 XHCI controller */
lib/fdtdec.c +0 -1
@@ -42,7 +42,6 @@ static const char * const compat_names[COMPAT_COUNT] = {COMPAT (SAMSUNG_S3C2440_I2C ,"samsung,s3c2440-i2c" ),COMPAT (SAMSUNG_EXYNOS5_SOUND ,"samsung,exynos-sound" ),COMPAT (WOLFSON_WM8994_CODEC ,"wolfson,wm8994-codec" ), -COMPAT (GOOGLE_CROS_EC ,"google,cros-ec" ),COMPAT (GOOGLE_CROS_EC_KEYB ,"google,cros-ec-keyb" ),COMPAT (SAMSUNG_EXYNOS_EHCI ,"samsung,exynos-ehci" ), COMPAT(SAMSUNG_EXYNOS5_XHCI, "samsung,exynos5250-xhci"),
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 14/16 fdt: Drop LPC compatible string in fdtdec
In reply to Simon GlassThis is not needed now that we have moved chromebook_link and cros_ec to driver model.
---
include/fdtdec.h | 1 - lib/fdtdec.c | 1 - 2 files changed, 2 deletions(-)
include/fdtdec.h +0 -1
@@ -158,7 +158,6 @@ enum fdt_compat_id {COMPAT_NXP_PTN3460 ,/* NXP PTN3460 DP/LVDS bridge */ COMPAT_SAMSUNG_EXYNOS_SYSMMU ,/* Exynos sysmmu */ COMPAT_PARADE_PS8625 ,/* Parade PS8622 EDP->LVDS bridge */ -COMPAT_INTEL_LPC ,/* Intel Low Pin Count I/F */ COMPAT_INTEL_MICROCODE ,/* Intel microcode update */ COMPAT_MEMORY_SPD ,/* Memory SPD information */ COMPAT_INTEL_PANTHERPOINT_AHCI, /* Intel Pantherpoint AHCI */
lib/fdtdec.c +0 -1
@@ -66,7 +66,6 @@ static const char * const compat_names[COMPAT_COUNT] = {COMPAT (COMPAT_NXP_PTN3460 ,"nxp,ptn3460" ),COMPAT (SAMSUNG_EXYNOS_SYSMMU ,"samsung,sysmmu-v3.3" ),COMPAT (PARADE_PS8625 ,"parade,ps8625" ), -COMPAT (COMPAT_INTEL_LPC ,"intel,bd82x6x-lpc" ),COMPAT (INTEL_MICROCODE ,"intel,microcode" ),COMPAT (MEMORY_SPD ,"memory-spd" ), COMPAT(INTEL_PANTHERPOINT_AHCI, "intel,pantherpoint-ahci"),
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 15/16 cros_ec: exynos: Match up device tree with kernel version
In reply to Simon GlassThe U-Boot device trees are slightly different in a few places. Adjust them to remove most of the differences. Note that U-Boot does not support the concept of interrupts as distinct from GPIOs, so this difference remains.
For sandbox, use the same keyboard file as for ARM boards and drop the host emulation bus which seems redundant.
---
arch/arm/dts/exynos5250-snow.dts | 7 +- arch/arm/dts/exynos5420-peach-pit.dts | 5 +- arch/arm/dts/exynos5800-peach-pi.dts | 4 +- arch/sandbox/dts/cros-ec-keyboard.dtsi | 105 ++++++++++++++++++++++++++++++ arch/sandbox/dts/sandbox.dts | 115 +++++++-------------------------- drivers/input/cros_ec_keyb.c | 2 +- drivers/misc/cros_ec_i2c.c | 4 +- drivers/misc/cros_ec_lpc.c | 4 +- drivers/misc/cros_ec_sandbox.c | 4 +- drivers/misc/cros_ec_spi.c | 4 +- include/fdtdec.h | 1 - lib/fdtdec.c | 1 - 12 files changed, 146 insertions(+), 110 deletions(-) create mode 100644 arch/sandbox/dts/cros-ec-keyboard.dtsi
arch/arm/dts/exynos5250-snow.dts +4 -3
@@ -65,9 +65,10 @@ spi at 131b0000 { spi-max-frequency = <1000000>; spi-deactivate-delay = <100>; - cros_ec: cros-ec at 0 { - reg = <0>; - compatible = "google,cros-ec"; + + cros_ec: embedded-controller { + compatible = "google,cros-ec-i2c"; + reg = <0x1e>; spi-max-frequency = <5000000>; ec-interrupt = <&gpx1 6 GPIO_ACTIVE_LOW>; optimise-flash-write;
arch/arm/dts/exynos5420-peach-pit.dts +2 -3
@@ -102,12 +102,11 @@ spi at 12d40000 { /* spi2 */ spi-max-frequency = <4000000>; spi-deactivate-delay = <200>; + cros_ec: cros-ec at 0 { + compatible = "google,cros-ec-spi"; reg = <0>; - compatible = "google,cros-ec"; - spi-half-duplex; spi-max-timeout-ms = <1100>; - spi-frame-header = <0xec>; ec-interrupt = <&gpx1 5 GPIO_ACTIVE_LOW>; /*
arch/arm/dts/exynos5800-peach-pi.dts +1 -3
@@ -97,11 +97,9 @@ spi-max-frequency = <4000000>; spi-deactivate-delay = <200>; cros_ec: cros-ec at 0 { + compatible = "google,cros-ec-spi"; reg = <0>; - compatible = "google,cros-ec"; - spi-half-duplex; spi-max-timeout-ms = <1100>; - spi-frame-header = <0xec>; ec-interrupt = <&gpx1 5 GPIO_ACTIVE_LOW>; /*
arch/sandbox/dts/cros-ec-keyboard.dtsi new file +105 -0
105 lines not on this page · raw message
arch/sandbox/dts/sandbox.dts +25 -90
145 lines not on this page · raw message
drivers/input/cros_ec_keyb.c +1 -1
@@ -198,7 +198,7 @@ static int cros_ec_keyb_decode_fdt(const void *blob, int node,return -1 ; } config->ghost_filter =fdtdec_get_bool (blob, node, -"google,ghost-filter" ); +"google,needs-ghost-filter" );return 0 ; }
drivers/misc/cros_ec_i2c.c +2 -2
@@ -139,12 +139,12 @@ static struct dm_cros_ec_ops cros_ec_ops = { };static const struct udevice_id cros_ec_ids[] = { - { .compatible ="google,cros-ec" }, + { .compatible ="google,cros-ec-i2c" }, { } };U_BOOT_DRIVER (cros_ec_i2c) = { - .name ="cros_ec" , + .name ="cros_ec_i2c" , .id =UCLASS_CROS_EC , .of_match = cros_ec_ids, .probe = cros_ec_probe,
drivers/misc/cros_ec_lpc.c +2 -2
@@ -206,12 +206,12 @@ static struct dm_cros_ec_ops cros_ec_ops = { };static const struct udevice_id cros_ec_ids[] = { - { .compatible ="google,cros-ec" }, + { .compatible ="google,cros-ec-lpc" }, { } };U_BOOT_DRIVER (cros_ec_lpc) = { - .name ="cros_ec" , + .name ="cros_ec_lpc" , .id =UCLASS_CROS_EC , .of_match = cros_ec_ids, .probe = cros_ec_probe,
drivers/misc/cros_ec_sandbox.c +2 -2
@@ -557,12 +557,12 @@ struct dm_cros_ec_ops cros_ec_ops = { };static const struct udevice_id cros_ec_ids[] = { - { .compatible ="google,cros-ec" }, + { .compatible ="google,cros-ec-sandbox" }, { } };U_BOOT_DRIVER (cros_ec_sandbox) = { - .name ="cros_ec" , + .name ="cros_ec_sandbox" , .id =UCLASS_CROS_EC , .of_match = cros_ec_ids, .probe = cros_ec_probe,
drivers/misc/cros_ec_spi.c +2 -2
@@ -165,12 +165,12 @@ static struct dm_cros_ec_ops cros_ec_ops = { };static const struct udevice_id cros_ec_ids[] = { - { .compatible ="google,cros-ec" }, + { .compatible ="google,cros-ec-spi" }, { } };U_BOOT_DRIVER (cros_ec_spi) = { - .name ="cros_ec" , + .name ="cros_ec_spi" , .id =UCLASS_CROS_EC , .of_match = cros_ec_ids, .probe = cros_ec_probe,
include/fdtdec.h +0 -1
@@ -152,7 +152,6 @@ enum fdt_compat_id {COMPAT_INFINEON_SLB9635_TPM ,/* Infineon SLB9635 TPM */ COMPAT_INFINEON_SLB9645_TPM ,/* Infineon SLB9645 TPM */ COMPAT_SAMSUNG_EXYNOS5_I2C ,/* Exynos5 High Speed I2C Controller */ -COMPAT_SANDBOX_HOST_EMULATION ,/* Sandbox emulation of a function */ COMPAT_SANDBOX_LCD_SDL ,/* Sandbox LCD emulation with SDL */ COMPAT_TI_TPS65090 ,/* Texas Instrument TPS65090 */ COMPAT_NXP_PTN3460, /* NXP PTN3460 DP/LVDS bridge */
lib/fdtdec.c +0 -1
@@ -60,7 +60,6 @@ static const char * const compat_names[COMPAT_COUNT] = {COMPAT (INFINEON_SLB9635_TPM ,"infineon,slb9635-tpm" ),COMPAT (INFINEON_SLB9645_TPM ,"infineon,slb9645-tpm" ),COMPAT (SAMSUNG_EXYNOS5_I2C ,"samsung,exynos5-hsi2c" ), -COMPAT (SANDBOX_HOST_EMULATION ,"sandbox,host-emulation" ),COMPAT (SANDBOX_LCD_SDL ,"sandbox,lcd-sdl" ),COMPAT (TI_TPS65090 ,"ti,tps65090" ), COMPAT(COMPAT_NXP_PTN3460, "nxp,ptn3460"),
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 16/16 i8042: Add keyboard enable logic in kbd_reset()
In reply to Simon GlassThis code appears to be missing a piece that is needed on some keyboards to enable the keyboard. Add this in.
This makes the keyboard work correctly on chromebook_link.
---
drivers/input/i8042.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/input/i8042.c +7 -0
@@ -698,7 +698,14 @@ static int kbd_reset(void)/* Enable Keyboard */ out8 (I8042_COMMAND_REG ,0xae ); +if (kbd_input_empty () ==0 ) +return -1 ; + +out8 (I8042_COMMAND_REG ,0x60 ); +if (kbd_input_empty () ==0 ) +return -1 ; +out8 (I8042_DATA_REG ,0xf4 );if (kbd_input_empty () ==0 )return -1 ;
Signature · 1 line
2.2.0.rc0.207.ga3a616c