Re: [PATCH v5 4/7] platform/chrome: Add Chrome OS EC userspace device interface

2015-02-26 Thread Olof Johansson
On Thu, Feb 26, 2015 at 1:08 AM, Javier Martinez Canillas
 wrote:
> Hello Olof,
>
> Thanks a lot for your feedback.
>
> On 02/26/2015 02:13 AM, Gwendal Grignou wrote:
>> Olof,
>>
>> I think the way Javier did it is fine, the 'major' of the ioctl is
>> 0xEC, from ':'.
>>
>> Gwendal.
>>
>
> As Gwendal said, I deliberately changed the IOCTL mayor number to
> make it different in both kernels.
>
> downstream:
>
> #define CROS_EC_DEV_IOC  ':'
> #define CROS_EC_DEV_IOCXCMD_IOWR(':', 0, struct cros_ec_command)
> #define CROS_EC_DEV_IOCRDMEM   _IOWR(':', 1, struct cros_ec_readmem)
>
> mainline:
>
> #define CROS_EC_DEV_IOC   0xEC
> #define CROS_EC_DEV_IOCXCMD   _IOWR(CROS_EC_DEV_IOC, 0, struct 
> cros_ec_command)
> #define CROS_EC_DEV_IOCRDMEM  _IOWR(CROS_EC_DEV_IOC, 1, struct 
> cros_ec_readmem)
>
> I can also do what you suggested and keep ':' as the major and use 2/3
> as command numbers but I just think 0xEC is a much nicer major for the
> interface to talk with the Embedded Controller and it was available ;)

No, changing major is definitely sufficient and an acceptable way to
do it -- I had missed that you did so.

Thanks, Javier, Gwendal, I'll apply this today and push out. Gwendal
has been giving it a go on a machine here too so I'll check with him
before I push.


-Olof
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 4/7] platform/chrome: Add Chrome OS EC userspace device interface

2015-02-26 Thread Javier Martinez Canillas
Hello Olof,

Thanks a lot for your feedback.

On 02/26/2015 02:13 AM, Gwendal Grignou wrote:
> Olof,
> 
> I think the way Javier did it is fine, the 'major' of the ioctl is
> 0xEC, from ':'.
> 
> Gwendal.
>

As Gwendal said, I deliberately changed the IOCTL mayor number to
make it different in both kernels.

downstream:

#define CROS_EC_DEV_IOC  ':'
#define CROS_EC_DEV_IOCXCMD_IOWR(':', 0, struct cros_ec_command)
#define CROS_EC_DEV_IOCRDMEM   _IOWR(':', 1, struct cros_ec_readmem)

mainline:

#define CROS_EC_DEV_IOC   0xEC
#define CROS_EC_DEV_IOCXCMD   _IOWR(CROS_EC_DEV_IOC, 0, struct cros_ec_command)
#define CROS_EC_DEV_IOCRDMEM  _IOWR(CROS_EC_DEV_IOC, 1, struct cros_ec_readmem)

I can also do what you suggested and keep ':' as the major and use 2/3
as command numbers but I just think 0xEC is a much nicer major for the
interface to talk with the Embedded Controller and it was available ;)

Best regards,
Javier
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 4/7] platform/chrome: Add Chrome OS EC userspace device interface

2015-02-25 Thread Gwendal Grignou
Olof,

I think the way Javier did it is fine, the 'major' of the ioctl is
0xEC, from ':'.

Gwendal.

On Wed, Feb 25, 2015 at 4:54 PM, Olof Johansson  wrote:
> On Mon, Feb 02, 2015 at 12:26:25PM +0100, Javier Martinez Canillas wrote:
>> From: Bill Richardson 
>>
>> This patch adds a device interface to access the
>> Chrome OS Embedded Controller from user-space.
>>
>> Signed-off-by: Bill Richardson 
>> Reviewed-by: Simon Glass 
>> Signed-off-by: Javier Martinez Canillas 
>> Reviewed-by: Gwendal Grignou 
>> ---
>>
>> Changes since v4: None.
>>
>> Changes since v3: None.
>>
>> Changes since v2:
>>  - Rename the devname to "cros-ec-ctl". Suggested by Lee Jones.
>>  - Added Gwendal Grignou Reviewed-by tag.
>>
>> Changes since v1: None, new patch.
>
> Hi,
>
>> ---
>>  Documentation/ioctl/ioctl-number.txt  |   1 +
>>  drivers/platform/chrome/Kconfig   |  14 +-
>>  drivers/platform/chrome/Makefile  |   1 +
>>  drivers/platform/chrome/cros_ec_dev.c | 268 
>> ++
>>  drivers/platform/chrome/cros_ec_dev.h |  47 ++
>>  5 files changed, 328 insertions(+), 3 deletions(-)
>>  create mode 100644 drivers/platform/chrome/cros_ec_dev.c
>>  create mode 100644 drivers/platform/chrome/cros_ec_dev.h
>>
>> diff --git a/Documentation/ioctl/ioctl-number.txt 
>> b/Documentation/ioctl/ioctl-number.txt
>> index 8136e1fd30fd..51f4221657bf 100644
>> --- a/Documentation/ioctl/ioctl-number.txt
>> +++ b/Documentation/ioctl/ioctl-number.txt
>> @@ -321,6 +321,7 @@ Code  Seq#(hex)   Include FileComments
>>  0xDB 00-0F   drivers/char/mwave/mwavepub.h
>>  0xDD 00-3F   ZFCP device driver  see drivers/s390/scsi/
>>   
>> +0xEC 00-01   drivers/platform/chrome/cros_ec_dev.h   ChromeOS EC driver
>
> It seems like a bad idea to reuse the same ioctl numbers as the out-of-tree
> driver but changing the arguments. So please allocate a few more and use 2/3
> for this calling interface.
>
> [...]
>
>> new file mode 100644
>> index ..15c54c4c5531
>> --- /dev/null
>> +++ b/drivers/platform/chrome/cros_ec_dev.h
>> @@ -0,0 +1,47 @@
>> +/*
>> + * cros_ec_dev - expose the Chrome OS Embedded Controller to userspace
>> + *
>> + * Copyright (C) 2014 Google, Inc.
>> + *
>> + * 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.
>> + *
>> + * 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.
>> + *
>> + * You should have received a copy of the GNU General Public License
>> + * along with this program. If not, see .
>> + */
>> +
>> +#ifndef _CROS_EC_DEV_H_
>> +#define _CROS_EC_DEV_H_
>> +
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#define CROS_EC_DEV_NAME "cros_ec"
>> +#define CROS_EC_DEV_VERSION "1.0.0"
>> +
>> +/*
>> + * @offset: within EC_LPC_ADDR_MEMMAP region
>> + * @bytes: number of bytes to read. zero means "read a string" (including 
>> '\0')
>> + * (at most only EC_MEMMAP_SIZE bytes can be read)
>> + * @buffer: where to store the result
>> + * ioctl returns the number of bytes read, negative on error
>> + */
>> +struct cros_ec_readmem {
>> + uint32_t offset;
>> + uint32_t bytes;
>> + uint8_t buffer[EC_MEMMAP_SIZE];
>> +};
>> +
>> +#define CROS_EC_DEV_IOC   0xEC
>> +#define CROS_EC_DEV_IOCXCMD   _IOWR(CROS_EC_DEV_IOC, 0, struct 
>> cros_ec_command)
>> +#define CROS_EC_DEV_IOCRDMEM  _IOWR(CROS_EC_DEV_IOC, 1, struct 
>> cros_ec_readmem)
>
> I.e. go with 2/3 here.
>
> (I can just do that change when I apply this patch, let me know if you prefer
> that).
>
>
> -Olof
>>
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 4/7] platform/chrome: Add Chrome OS EC userspace device interface

2015-02-25 Thread Olof Johansson
On Mon, Feb 02, 2015 at 12:26:25PM +0100, Javier Martinez Canillas wrote:
> From: Bill Richardson 
> 
> This patch adds a device interface to access the
> Chrome OS Embedded Controller from user-space.
> 
> Signed-off-by: Bill Richardson 
> Reviewed-by: Simon Glass 
> Signed-off-by: Javier Martinez Canillas 
> Reviewed-by: Gwendal Grignou 
> ---
> 
> Changes since v4: None.
> 
> Changes since v3: None.
> 
> Changes since v2:
>  - Rename the devname to "cros-ec-ctl". Suggested by Lee Jones.
>  - Added Gwendal Grignou Reviewed-by tag.
> 
> Changes since v1: None, new patch.

Hi,

> ---
>  Documentation/ioctl/ioctl-number.txt  |   1 +
>  drivers/platform/chrome/Kconfig   |  14 +-
>  drivers/platform/chrome/Makefile  |   1 +
>  drivers/platform/chrome/cros_ec_dev.c | 268 
> ++
>  drivers/platform/chrome/cros_ec_dev.h |  47 ++
>  5 files changed, 328 insertions(+), 3 deletions(-)
>  create mode 100644 drivers/platform/chrome/cros_ec_dev.c
>  create mode 100644 drivers/platform/chrome/cros_ec_dev.h
> 
> diff --git a/Documentation/ioctl/ioctl-number.txt 
> b/Documentation/ioctl/ioctl-number.txt
> index 8136e1fd30fd..51f4221657bf 100644
> --- a/Documentation/ioctl/ioctl-number.txt
> +++ b/Documentation/ioctl/ioctl-number.txt
> @@ -321,6 +321,7 @@ Code  Seq#(hex)   Include FileComments
>  0xDB 00-0F   drivers/char/mwave/mwavepub.h
>  0xDD 00-3F   ZFCP device driver  see drivers/s390/scsi/
>   
> +0xEC 00-01   drivers/platform/chrome/cros_ec_dev.h   ChromeOS EC driver

It seems like a bad idea to reuse the same ioctl numbers as the out-of-tree
driver but changing the arguments. So please allocate a few more and use 2/3
for this calling interface.

[...]

> new file mode 100644
> index ..15c54c4c5531
> --- /dev/null
> +++ b/drivers/platform/chrome/cros_ec_dev.h
> @@ -0,0 +1,47 @@
> +/*
> + * cros_ec_dev - expose the Chrome OS Embedded Controller to userspace
> + *
> + * Copyright (C) 2014 Google, Inc.
> + *
> + * 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.
> + *
> + * 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.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program. If not, see .
> + */
> +
> +#ifndef _CROS_EC_DEV_H_
> +#define _CROS_EC_DEV_H_
> +
> +#include 
> +#include 
> +#include 
> +
> +#define CROS_EC_DEV_NAME "cros_ec"
> +#define CROS_EC_DEV_VERSION "1.0.0"
> +
> +/*
> + * @offset: within EC_LPC_ADDR_MEMMAP region
> + * @bytes: number of bytes to read. zero means "read a string" (including 
> '\0')
> + * (at most only EC_MEMMAP_SIZE bytes can be read)
> + * @buffer: where to store the result
> + * ioctl returns the number of bytes read, negative on error
> + */
> +struct cros_ec_readmem {
> + uint32_t offset;
> + uint32_t bytes;
> + uint8_t buffer[EC_MEMMAP_SIZE];
> +};
> +
> +#define CROS_EC_DEV_IOC   0xEC
> +#define CROS_EC_DEV_IOCXCMD   _IOWR(CROS_EC_DEV_IOC, 0, struct 
> cros_ec_command)
> +#define CROS_EC_DEV_IOCRDMEM  _IOWR(CROS_EC_DEV_IOC, 1, struct 
> cros_ec_readmem)

I.e. go with 2/3 here.

(I can just do that change when I apply this patch, let me know if you prefer
that).


-Olof
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 4/7] platform/chrome: Add Chrome OS EC userspace device interface

2015-02-02 Thread Javier Martinez Canillas
From: Bill Richardson 

This patch adds a device interface to access the
Chrome OS Embedded Controller from user-space.

Signed-off-by: Bill Richardson 
Reviewed-by: Simon Glass 
Signed-off-by: Javier Martinez Canillas 
Reviewed-by: Gwendal Grignou 
---

Changes since v4: None.

Changes since v3: None.

Changes since v2:
 - Rename the devname to "cros-ec-ctl". Suggested by Lee Jones.
 - Added Gwendal Grignou Reviewed-by tag.

Changes since v1: None, new patch.
---
 Documentation/ioctl/ioctl-number.txt  |   1 +
 drivers/platform/chrome/Kconfig   |  14 +-
 drivers/platform/chrome/Makefile  |   1 +
 drivers/platform/chrome/cros_ec_dev.c | 268 ++
 drivers/platform/chrome/cros_ec_dev.h |  47 ++
 5 files changed, 328 insertions(+), 3 deletions(-)
 create mode 100644 drivers/platform/chrome/cros_ec_dev.c
 create mode 100644 drivers/platform/chrome/cros_ec_dev.h

diff --git a/Documentation/ioctl/ioctl-number.txt 
b/Documentation/ioctl/ioctl-number.txt
index 8136e1fd30fd..51f4221657bf 100644
--- a/Documentation/ioctl/ioctl-number.txt
+++ b/Documentation/ioctl/ioctl-number.txt
@@ -321,6 +321,7 @@ Code  Seq#(hex) Include FileComments
 0xDB   00-0F   drivers/char/mwave/mwavepub.h
 0xDD   00-3F   ZFCP device driver  see drivers/s390/scsi/

+0xEC   00-01   drivers/platform/chrome/cros_ec_dev.h   ChromeOS EC driver
 0xF3   00-3F   drivers/usb/misc/sisusbvga/sisusb.h sisfb (in development)

 0xF4   00-1F   video/mbxfb.h   mbxfb
diff --git a/drivers/platform/chrome/Kconfig b/drivers/platform/chrome/Kconfig
index 6c5f5a1e1175..d4befbffae85 100644
--- a/drivers/platform/chrome/Kconfig
+++ b/drivers/platform/chrome/Kconfig
@@ -4,7 +4,7 @@
 
 menuconfig CHROME_PLATFORMS
bool "Platform support for Chrome hardware"
-   depends on X86
+   depends on X86 || ARM
---help---
  Say Y here to get to see options for platform support for
  various Chromebooks and Chromeboxes. This option alone does
@@ -16,8 +16,7 @@ if CHROME_PLATFORMS
 
 config CHROMEOS_LAPTOP
tristate "Chrome OS Laptop"
-   depends on I2C
-   depends on DMI
+   depends on I2C && DMI && X86
---help---
  This driver instantiates i2c and smbus devices such as
  light sensors and touchpads.
@@ -27,6 +26,7 @@ config CHROMEOS_LAPTOP
 
 config CHROMEOS_PSTORE
tristate "Chrome OS pstore support"
+   depends on X86
---help---
  This module instantiates the persistent storage on x86 ChromeOS
  devices. It can be used to store away console logs and crash
@@ -38,6 +38,14 @@ config CHROMEOS_PSTORE
  If you have a supported Chromebook, choose Y or M here.
  The module will be called chromeos_pstore.
 
+config CROS_EC_CHARDEV
+tristate "Chrome OS Embedded Controller userspace device interface"
+depends on MFD_CROS_EC
+---help---
+  This driver adds support to talk with the ChromeOS EC from userspace.
+
+  If you have a supported Chromebook, choose Y or M here.
+  The module will be called cros_ec_dev.
 
 config CROS_EC_LPC
 tristate "ChromeOS Embedded Controller (LPC)"
diff --git a/drivers/platform/chrome/Makefile b/drivers/platform/chrome/Makefile
index 03c0260369d9..ec682900f889 100644
--- a/drivers/platform/chrome/Makefile
+++ b/drivers/platform/chrome/Makefile
@@ -1,4 +1,5 @@
 
 obj-$(CONFIG_CHROMEOS_LAPTOP)  += chromeos_laptop.o
 obj-$(CONFIG_CHROMEOS_PSTORE)  += chromeos_pstore.o
+obj-$(CONFIG_CROS_EC_CHARDEV)   += cros_ec_dev.o
 obj-$(CONFIG_CROS_EC_LPC)   += cros_ec_lpc.o
diff --git a/drivers/platform/chrome/cros_ec_dev.c 
b/drivers/platform/chrome/cros_ec_dev.c
new file mode 100644
index ..94c1442d5104
--- /dev/null
+++ b/drivers/platform/chrome/cros_ec_dev.c
@@ -0,0 +1,268 @@
+/*
+ * cros_ec_dev - expose the Chrome OS Embedded Controller to user-space
+ *
+ * Copyright (C) 2014 Google, Inc.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include "cros_ec_dev.h"
+
+/* Device variables */
+#define CROS_MAX_DEV 128
+static struct class *cros_class;
+static int ec_major;
+
+/* Basic communication */
+static