Re: [PATCH 06/13] platform/chrome: cros_ec_lpc: Add support for mec1322 EC

2017-03-23 Thread Lee Jones
On Fri, 17 Mar 2017, Enric Balletbo i Serra wrote:

> From: Shawn Nematbakhsh 
> 
> This adds support for the ChromeOS LPC Microchip Embedded Controller
> (mec1322) variant.
> 
> mec1322 accesses I/O region [800h, 9ffh] through embedded memory
> interface (EMI) rather than LPC.
> 
> Signed-off-by: Shawn Nematbakhsh 
> Signed-off-by: Thierry Escande 
> ---
> Changelog:
>  - v2:
>-Add a few lines in Kconfig description
>-Fixed coding style issues
>-Updated copyright to year 2016
> 
>  drivers/platform/chrome/Kconfig   |  12 +++
>  drivers/platform/chrome/Makefile  |   1 +
>  drivers/platform/chrome/cros_ec_lpc.c |   5 ++
>  drivers/platform/chrome/cros_ec_lpc_mec.c | 140 
> ++
>  drivers/platform/chrome/cros_ec_lpc_reg.c |  69 +++

>  include/linux/mfd/cros_ec_lpc_mec.h   |  90 +++
>  include/linux/mfd/cros_ec_lpc_reg.h   |  14 +++

Acked-by: Lee Jones 

>  7 files changed, 331 insertions(+)
>  create mode 100644 drivers/platform/chrome/cros_ec_lpc_mec.c
>  create mode 100644 include/linux/mfd/cros_ec_lpc_mec.h
> 
> diff --git a/drivers/platform/chrome/Kconfig b/drivers/platform/chrome/Kconfig
> index 76bdae1..6d80fb5 100644
> --- a/drivers/platform/chrome/Kconfig
> +++ b/drivers/platform/chrome/Kconfig
> @@ -59,6 +59,18 @@ config CROS_EC_LPC
>To compile this driver as a module, choose M here: the
>module will be called cros_ec_lpc.
>  
> +config CROS_EC_LPC_MEC
> + bool "ChromeOS Embedded Controller LPC Microchip EC (MEC) variant"
> + depends on CROS_EC_LPC
> + default n
> + help
> +   If you say Y here, a variant LPC protocol for the Microchip EC
> +   will be used. Note that this variant is not backward compatible
> +   with non-Microchip ECs.
> +
> +   If you have a ChromeOS Embedded Controller Microchip EC variant
> +   choose Y here.
> +
>  config CROS_EC_PROTO
>  bool
>  help
> diff --git a/drivers/platform/chrome/Makefile 
> b/drivers/platform/chrome/Makefile
> index 61182fd..66c345c 100644
> --- a/drivers/platform/chrome/Makefile
> +++ b/drivers/platform/chrome/Makefile
> @@ -6,6 +6,7 @@ cros_ec_devs-objs := cros_ec_dev.o 
> cros_ec_sysfs.o \
>  cros_ec_debugfs.o
>  obj-$(CONFIG_CROS_EC_CHARDEV)+= cros_ec_devs.o
>  cros_ec_lpcs-objs:= cros_ec_lpc.o cros_ec_lpc_reg.o
> +cros_ec_lpcs-$(CONFIG_CROS_EC_LPC_MEC)   += cros_ec_lpc_mec.o
>  obj-$(CONFIG_CROS_EC_LPC)+= cros_ec_lpcs.o
>  obj-$(CONFIG_CROS_EC_PROTO)  += cros_ec_proto.o
>  obj-$(CONFIG_CROS_KBD_LED_BACKLIGHT) += cros_kbd_led_backlight.o
> diff --git a/drivers/platform/chrome/cros_ec_lpc.c 
> b/drivers/platform/chrome/cros_ec_lpc.c
> index 6a782a6..bc2dc62 100644
> --- a/drivers/platform/chrome/cros_ec_lpc.c
> +++ b/drivers/platform/chrome/cros_ec_lpc.c
> @@ -346,10 +346,13 @@ static int __init cros_ec_lpc_init(void)
>   return -ENODEV;
>   }
>  
> + cros_ec_lpc_reg_init();
> +
>   /* Register the driver */
>   ret = platform_driver_register(_ec_lpc_driver);
>   if (ret) {
>   pr_err(DRV_NAME ": can't register driver: %d\n", ret);
> + cros_ec_lpc_reg_destroy();
>   return ret;
>   }
>  
> @@ -358,6 +361,7 @@ static int __init cros_ec_lpc_init(void)
>   if (ret) {
>   pr_err(DRV_NAME ": can't register device: %d\n", ret);
>   platform_driver_unregister(_ec_lpc_driver);
> + cros_ec_lpc_reg_destroy();
>   return ret;
>   }
>  
> @@ -368,6 +372,7 @@ static void __exit cros_ec_lpc_exit(void)
>  {
>   platform_device_unregister(_ec_lpc_device);
>   platform_driver_unregister(_ec_lpc_driver);
> + cros_ec_lpc_reg_destroy();
>  }
>  
>  module_init(cros_ec_lpc_init);
> diff --git a/drivers/platform/chrome/cros_ec_lpc_mec.c 
> b/drivers/platform/chrome/cros_ec_lpc_mec.c
> new file mode 100644
> index 000..2eda2c2
> --- /dev/null
> +++ b/drivers/platform/chrome/cros_ec_lpc_mec.c
> @@ -0,0 +1,140 @@
> +/*
> + * cros_ec_lpc_mec - LPC variant I/O for Microchip EC
> + *
> + * Copyright (C) 2016 Google, Inc
> + *
> + * This software is licensed under the terms of the GNU General Public
> + * License version 2, as published by the Free Software Foundation, and
> + * may be copied, distributed, and modified under those terms.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * This driver uses the Chrome OS EC byte-level message-based protocol for
> + * communicating the keyboard state (which keys are pressed) from a 

Re: [PATCH 06/13] platform/chrome: cros_ec_lpc: Add support for mec1322 EC

2017-03-23 Thread Lee Jones
On Fri, 17 Mar 2017, Enric Balletbo i Serra wrote:

> From: Shawn Nematbakhsh 
> 
> This adds support for the ChromeOS LPC Microchip Embedded Controller
> (mec1322) variant.
> 
> mec1322 accesses I/O region [800h, 9ffh] through embedded memory
> interface (EMI) rather than LPC.
> 
> Signed-off-by: Shawn Nematbakhsh 
> Signed-off-by: Thierry Escande 
> ---
> Changelog:
>  - v2:
>-Add a few lines in Kconfig description
>-Fixed coding style issues
>-Updated copyright to year 2016
> 
>  drivers/platform/chrome/Kconfig   |  12 +++
>  drivers/platform/chrome/Makefile  |   1 +
>  drivers/platform/chrome/cros_ec_lpc.c |   5 ++
>  drivers/platform/chrome/cros_ec_lpc_mec.c | 140 
> ++
>  drivers/platform/chrome/cros_ec_lpc_reg.c |  69 +++

>  include/linux/mfd/cros_ec_lpc_mec.h   |  90 +++
>  include/linux/mfd/cros_ec_lpc_reg.h   |  14 +++

Acked-by: Lee Jones 

>  7 files changed, 331 insertions(+)
>  create mode 100644 drivers/platform/chrome/cros_ec_lpc_mec.c
>  create mode 100644 include/linux/mfd/cros_ec_lpc_mec.h
> 
> diff --git a/drivers/platform/chrome/Kconfig b/drivers/platform/chrome/Kconfig
> index 76bdae1..6d80fb5 100644
> --- a/drivers/platform/chrome/Kconfig
> +++ b/drivers/platform/chrome/Kconfig
> @@ -59,6 +59,18 @@ config CROS_EC_LPC
>To compile this driver as a module, choose M here: the
>module will be called cros_ec_lpc.
>  
> +config CROS_EC_LPC_MEC
> + bool "ChromeOS Embedded Controller LPC Microchip EC (MEC) variant"
> + depends on CROS_EC_LPC
> + default n
> + help
> +   If you say Y here, a variant LPC protocol for the Microchip EC
> +   will be used. Note that this variant is not backward compatible
> +   with non-Microchip ECs.
> +
> +   If you have a ChromeOS Embedded Controller Microchip EC variant
> +   choose Y here.
> +
>  config CROS_EC_PROTO
>  bool
>  help
> diff --git a/drivers/platform/chrome/Makefile 
> b/drivers/platform/chrome/Makefile
> index 61182fd..66c345c 100644
> --- a/drivers/platform/chrome/Makefile
> +++ b/drivers/platform/chrome/Makefile
> @@ -6,6 +6,7 @@ cros_ec_devs-objs := cros_ec_dev.o 
> cros_ec_sysfs.o \
>  cros_ec_debugfs.o
>  obj-$(CONFIG_CROS_EC_CHARDEV)+= cros_ec_devs.o
>  cros_ec_lpcs-objs:= cros_ec_lpc.o cros_ec_lpc_reg.o
> +cros_ec_lpcs-$(CONFIG_CROS_EC_LPC_MEC)   += cros_ec_lpc_mec.o
>  obj-$(CONFIG_CROS_EC_LPC)+= cros_ec_lpcs.o
>  obj-$(CONFIG_CROS_EC_PROTO)  += cros_ec_proto.o
>  obj-$(CONFIG_CROS_KBD_LED_BACKLIGHT) += cros_kbd_led_backlight.o
> diff --git a/drivers/platform/chrome/cros_ec_lpc.c 
> b/drivers/platform/chrome/cros_ec_lpc.c
> index 6a782a6..bc2dc62 100644
> --- a/drivers/platform/chrome/cros_ec_lpc.c
> +++ b/drivers/platform/chrome/cros_ec_lpc.c
> @@ -346,10 +346,13 @@ static int __init cros_ec_lpc_init(void)
>   return -ENODEV;
>   }
>  
> + cros_ec_lpc_reg_init();
> +
>   /* Register the driver */
>   ret = platform_driver_register(_ec_lpc_driver);
>   if (ret) {
>   pr_err(DRV_NAME ": can't register driver: %d\n", ret);
> + cros_ec_lpc_reg_destroy();
>   return ret;
>   }
>  
> @@ -358,6 +361,7 @@ static int __init cros_ec_lpc_init(void)
>   if (ret) {
>   pr_err(DRV_NAME ": can't register device: %d\n", ret);
>   platform_driver_unregister(_ec_lpc_driver);
> + cros_ec_lpc_reg_destroy();
>   return ret;
>   }
>  
> @@ -368,6 +372,7 @@ static void __exit cros_ec_lpc_exit(void)
>  {
>   platform_device_unregister(_ec_lpc_device);
>   platform_driver_unregister(_ec_lpc_driver);
> + cros_ec_lpc_reg_destroy();
>  }
>  
>  module_init(cros_ec_lpc_init);
> diff --git a/drivers/platform/chrome/cros_ec_lpc_mec.c 
> b/drivers/platform/chrome/cros_ec_lpc_mec.c
> new file mode 100644
> index 000..2eda2c2
> --- /dev/null
> +++ b/drivers/platform/chrome/cros_ec_lpc_mec.c
> @@ -0,0 +1,140 @@
> +/*
> + * cros_ec_lpc_mec - LPC variant I/O for Microchip EC
> + *
> + * Copyright (C) 2016 Google, Inc
> + *
> + * This software is licensed under the terms of the GNU General Public
> + * License version 2, as published by the Free Software Foundation, and
> + * may be copied, distributed, and modified under those terms.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * This driver uses the Chrome OS EC byte-level message-based protocol for
> + * communicating the keyboard state (which keys are pressed) from a keyboard 
> EC
> + * to the AP over some bus (such as i2c, lpc, spi).  The EC does debouncing,
> +