[PATCH v2 2/3] platform/chrome: Support reading/writing the vboot context

2015-09-14 Thread Emilio López
Some EC implementations include a small nvram space used to store
verified boot context data. This patch offers a way to expose this
data to userspace.

Signed-off-by: Emilio López 
---
Changes from v1:
 - Use is_bin_visible instead of is_visible

 Documentation/devicetree/bindings/mfd/cros-ec.txt |   4 +
 drivers/platform/chrome/Makefile  |   5 +-
 drivers/platform/chrome/cros_ec_dev.c |   1 +
 drivers/platform/chrome/cros_ec_vbc.c | 137 ++
 include/linux/mfd/cros_ec.h   |   1 +
 5 files changed, 147 insertions(+), 1 deletion(-)
 create mode 100644 drivers/platform/chrome/cros_ec_vbc.c

diff --git a/Documentation/devicetree/bindings/mfd/cros-ec.txt 
b/Documentation/devicetree/bindings/mfd/cros-ec.txt
index 1777916..136e0c2 100644
--- a/Documentation/devicetree/bindings/mfd/cros-ec.txt
+++ b/Documentation/devicetree/bindings/mfd/cros-ec.txt
@@ -34,6 +34,10 @@ Required properties (LPC):
 - compatible: "google,cros-ec-lpc"
 - reg: List of (IO address, size) pairs defining the interface uses
 
+Optional properties (all):
+- google,has-vbc-nvram: Some implementations of the EC include a small
+  nvram space used to store verified boot context data. This boolean flag
+  is used to specify whether this nvram is present or not.
 
 Example for I2C:
 
diff --git a/drivers/platform/chrome/Makefile b/drivers/platform/chrome/Makefile
index 4a11b01..787be61 100644
--- a/drivers/platform/chrome/Makefile
+++ b/drivers/platform/chrome/Makefile
@@ -1,7 +1,10 @@
 
 obj-$(CONFIG_CHROMEOS_LAPTOP)  += chromeos_laptop.o
 obj-$(CONFIG_CHROMEOS_PSTORE)  += chromeos_pstore.o
-cros_ec_devs-objs   := cros_ec_dev.o cros_ec_sysfs.o 
cros_ec_lightbar.o
+cros_ec_devs-objs   := cros_ec_dev.o
+cros_ec_devs-objs   += cros_ec_lightbar.o
+cros_ec_devs-objs   += cros_ec_sysfs.o
+cros_ec_devs-objs   += cros_ec_vbc.o
 obj-$(CONFIG_CROS_EC_CHARDEV)   += cros_ec_devs.o
 obj-$(CONFIG_CROS_EC_LPC)   += cros_ec_lpc.o
 obj-$(CONFIG_CROS_EC_PROTO)+= cros_ec_proto.o
diff --git a/drivers/platform/chrome/cros_ec_dev.c 
b/drivers/platform/chrome/cros_ec_dev.c
index e8fcdc2..d19263f 100644
--- a/drivers/platform/chrome/cros_ec_dev.c
+++ b/drivers/platform/chrome/cros_ec_dev.c
@@ -32,6 +32,7 @@ static int ec_major;
 static const struct attribute_group *cros_ec_groups[] = {
_ec_attr_group,
_ec_lightbar_attr_group,
+   _ec_vbc_attr_group,
NULL,
 };
 
diff --git a/drivers/platform/chrome/cros_ec_vbc.c 
b/drivers/platform/chrome/cros_ec_vbc.c
new file mode 100644
index 000..a0e8d38
--- /dev/null
+++ b/drivers/platform/chrome/cros_ec_vbc.c
@@ -0,0 +1,137 @@
+/*
+ * cros_ec_vbc - Expose the vboot context nvram to userspace
+ *
+ * Copyright (C) 2015 Collabora Ltd.
+ *
+ * based on vendor driver,
+ *
+ * Copyright (C) 2012 The Chromium OS Authors
+ *
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static ssize_t vboot_context_read(struct file *filp, struct kobject *kobj,
+ struct bin_attribute *att, char *buf,
+ loff_t pos, size_t count)
+{
+   struct device *dev = container_of(kobj, struct device, kobj);
+   struct cros_ec_dev *ec = container_of(dev, struct cros_ec_dev,
+ class_dev);
+   struct cros_ec_device *ecdev = ec->ec_dev;
+   struct ec_params_vbnvcontext *params;
+   struct cros_ec_command *msg;
+   int err;
+   const size_t para_sz = sizeof(struct ec_params_vbnvcontext);
+   const size_t resp_sz = sizeof(struct ec_response_vbnvcontext);
+   const size_t payload = max(para_sz, resp_sz);
+
+   msg = kmalloc(sizeof(*msg) + payload, GFP_KERNEL);
+   if (!msg)
+   return -ENOMEM;
+
+   params = (struct ec_params_vbnvcontext *)msg->data;
+   params->op = EC_VBNV_CONTEXT_OP_READ;
+
+   msg->version = EC_VER_VBNV_CONTEXT;
+   msg->command = EC_CMD_VBNV_CONTEXT;
+   msg->outsize = sizeof(params->op);
+   msg->insize = resp_sz;
+
+   err = cros_ec_cmd_xfer(ecdev, msg);
+   if (err < 0) {
+   dev_err(dev, "Error sending read request: %d\n", err);
+   kfree(msg);
+   return err;
+   }
+
+   BUILD_BUG_ON(resp_sz > PAGE_SIZE);
+   memcpy(buf, msg->data, resp_sz);
+
+   kfree(msg);
+   return 

[PATCH v2 0/3] platform/chrome: vboot context support

2015-09-14 Thread Emilio López
Hi everyone,

This series adds support for reading and writing the verified boot context
nvram space on the EC using the cros_ec sysfs interface.

The first patch improves is_visible() functionality, making it work
for binary attributes as well as normal ones. This is needed so the
sysfs group can be hidden when the EC doesn't offer any space for
the context.

The second patch is the actual code implementing the interface to read
and write the context data.

The third patch adds the DT properties on peach boards which, judging by
the vendor tree, use the EC to store the verified boot context.

The series was tested on a peach pi and was found to work OK there. As
always, all comments and further tests are welcome :)

Cheers!
Emilio

Emilio López (3):
  sysfs: Support is_visible() on binary attributes
  platform/chrome: Support reading/writing the vboot context
  ARM: dts: Enable EC vboot context support on Peach boards

 Documentation/devicetree/bindings/mfd/cros-ec.txt |   4 +
 arch/arm/boot/dts/exynos5420-peach-pit.dts|   1 +
 arch/arm/boot/dts/exynos5800-peach-pi.dts |   1 +
 drivers/platform/chrome/Makefile  |   5 +-
 drivers/platform/chrome/cros_ec_dev.c |   1 +
 drivers/platform/chrome/cros_ec_vbc.c | 137 ++
 fs/sysfs/group.c  |  17 ++-
 include/linux/mfd/cros_ec.h   |   1 +
 include/linux/sysfs.h |  18 ++-
 9 files changed, 178 insertions(+), 7 deletions(-)
 create mode 100644 drivers/platform/chrome/cros_ec_vbc.c

-- 
2.1.4

--
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


[RESEND v2] mfd: s2mps11: Add manual shutdown method for Odroid XU3

2015-09-14 Thread Krzysztof Kozlowski
On Odroid XU3 board (with S2MPS11 PMIC) the PWRHOLD bit in CTRL1
register must be manually set to 0 before initiating power off sequence.

One of usual power down methods for Exynos based devices looks like:
1. PWRHOLD pin of PMIC is connected to PSHOLD of Exynos SoC.
2. Exynos holds up this pin during system operation.
3. ACOKB pin of PMIC is pulled up to VBATT and optionally to pin in
   other device.
4. When PWRHOLD/PSHOLD goes low, the PMIC will turn off the power if
   ACOKB goes high.

On Odroid XU3 family the difference is in (3) - the ACOKB is grounded.
This means that PMIC must manually set PWRHOLD field to low and then
wait for signal from Application Processor (the usual change in
PWRHOLD/PSHOLD pin will actually cut off the power).

The patch adds respective binding allowing Odroid XU3 device to be
powered off.

Signed-off-by: Krzysztof Kozlowski 
Reported-by: Anand Moon 
Tested-by: Anand Moon 
Reviewed-by: Javier Martinez Canillas 
Acked-by: Lee Jones 

---

The rest of patchset was applied by Kukjin Kim:
 - dt-bindings documentation:
   
https://git.kernel.org/cgit/linux/kernel/git/kgene/linux-samsung.git/commit/?h=v4.3-next/dt-samsung-new-3=ff1020841cf0ff868d61d44169e7cc32f73599b8
 - DTS change:
   
https://git.kernel.org/cgit/linux/kernel/git/kgene/linux-samsung.git/commit/?h=v4.3-next/dt-samsung-new-3=5bcbe4ba55bb0ad75c8495ee295bab036735483e

Changes since v2:
1. Just rebase on current next.

Changes since v1:
1. Split bindings documentation to separate patch (suggested by Lee).
2. Fix additional empty line (suggested by Lee).
3. Add Anand's tested-by, Javier's reviewed-by and Lee's acked-by.

Patch is losely based on patch in Hardkernel repository and previous
work of Anand Moon.
---
 drivers/mfd/sec-core.c  | 30 ++
 include/linux/mfd/samsung/core.h|  2 ++
 include/linux/mfd/samsung/s2mps11.h |  1 +
 3 files changed, 33 insertions(+)

diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c
index d206a3e8fe87..2d1137a7a0ee 100644
--- a/drivers/mfd/sec-core.c
+++ b/drivers/mfd/sec-core.c
@@ -278,6 +278,8 @@ static struct sec_platform_data 
*sec_pmic_i2c_parse_dt_pdata(
 * not parsed here.
 */
 
+   pd->manual_poweroff = of_property_read_bool(dev->of_node,
+   "samsung,s2mps11-acokb-ground");
return pd;
 }
 #else
@@ -440,6 +442,33 @@ static int sec_pmic_remove(struct i2c_client *i2c)
return 0;
 }
 
+static void sec_pmic_shutdown(struct i2c_client *i2c)
+{
+   struct sec_pmic_dev *sec_pmic = i2c_get_clientdata(i2c);
+   unsigned int reg, mask;
+
+   if (!sec_pmic->pdata->manual_poweroff)
+   return;
+
+   switch (sec_pmic->device_type) {
+   case S2MPS11X:
+   reg = S2MPS11_REG_CTRL1;
+   mask = S2MPS11_CTRL1_PWRHOLD_MASK;
+   break;
+   default:
+   /*
+* Currently only one board with S2MPS11 needs this, so just
+* ignore the rest.
+*/
+   dev_warn(sec_pmic->dev,
+   "Unsupported device %lu for manual power off\n",
+   sec_pmic->device_type);
+   return;
+   }
+
+   regmap_update_bits(sec_pmic->regmap_pmic, reg, mask, 0);
+}
+
 #ifdef CONFIG_PM_SLEEP
 static int sec_pmic_suspend(struct device *dev)
 {
@@ -491,6 +520,7 @@ static struct i2c_driver sec_pmic_driver = {
},
.probe = sec_pmic_probe,
.remove = sec_pmic_remove,
+   .shutdown = sec_pmic_shutdown,
.id_table = sec_pmic_id,
 };
 
diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h
index 75115384f3fc..aa78957e092f 100644
--- a/include/linux/mfd/samsung/core.h
+++ b/include/linux/mfd/samsung/core.h
@@ -132,6 +132,8 @@ struct sec_platform_data {
int buck2_init;
int buck3_init;
int buck4_init;
+   /* Whether or not manually set PWRHOLD to low during shutdown. */
+   boolmanual_poweroff;
 };
 
 /**
diff --git a/include/linux/mfd/samsung/s2mps11.h 
b/include/linux/mfd/samsung/s2mps11.h
index 7981a9d77d3f..b288965e8101 100644
--- a/include/linux/mfd/samsung/s2mps11.h
+++ b/include/linux/mfd/samsung/s2mps11.h
@@ -179,6 +179,7 @@ enum s2mps11_regulators {
 #define S2MPS11_BUCK_N_VOLTAGES (S2MPS11_BUCK_VSEL_MASK + 1)
 #define S2MPS11_RAMP_DELAY 25000   /* uV/us */
 
+#define S2MPS11_CTRL1_PWRHOLD_MASK BIT(4)
 
 #define S2MPS11_BUCK2_RAMP_SHIFT   6
 #define S2MPS11_BUCK34_RAMP_SHIFT  4
-- 
2.1.4

--
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  

[PATCH v2] ARM: exynos_defconfig: Enable USB Video Class support

2015-09-14 Thread Javier Martinez Canillas
The Exynos5420 Peach Pit and Exynos5800 Peach Pi boards have a built-in
Silicon Motion USB UVC WebCam. Enable support for the USB Video Class
driver and its needed media Kconfig symbols so the camera is supported.

Signed-off-by: Javier Martinez Canillas 

---

Changes in v2:
- Enable tristate Kconfig options as module instead of built-in.
  Suggested by Krzysztof Kozlowski.

 arch/arm/configs/exynos_defconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/configs/exynos_defconfig 
b/arch/arm/configs/exynos_defconfig
index 711cb0a3893d..d4f6063d8a72 100644
--- a/arch/arm/configs/exynos_defconfig
+++ b/arch/arm/configs/exynos_defconfig
@@ -126,6 +126,10 @@ CONFIG_REGULATOR_S2MPA01=y
 CONFIG_REGULATOR_S2MPS11=y
 CONFIG_REGULATOR_S5M8767=y
 CONFIG_REGULATOR_TPS65090=y
+CONFIG_MEDIA_SUPPORT=m
+CONFIG_MEDIA_CAMERA_SUPPORT=y
+CONFIG_MEDIA_USB_SUPPORT=y
+CONFIG_USB_VIDEO_CLASS=m
 CONFIG_DRM=y
 CONFIG_DRM_NXP_PTN3460=y
 CONFIG_DRM_PARADE_PS8622=y
-- 
2.4.3

--
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 v2 2/2] [media] media-device: split media initialization and registration

2015-09-14 Thread Javier Martinez Canillas
The media device node is registered and so made visible to user-space
before entities are registered and links created which means that the
media graph obtained by user-space could be only partially enumerated
if that happens too early before all the graph has been created.

To avoid this race condition, split the media init and registration
in separate functions and only register the media device node when
all the pending subdevices have been registered, either explicitly
by the driver or asynchronously using v4l2_async_register_subdev().

The media_device_register() had a check for drivers not filling dev
and model fields but all drivers in mainline set them so it was just
being paranoid. Remove the check so media_device_init() can return
void and the error handling removed from the drivers to simplify.

Also, add a media_device_cleanup() function that will destroy the
graph_mutex that is initialized in media_device_init().

Suggested-by: Sakari Ailus 
Signed-off-by: Javier Martinez Canillas 

---

Changes in v2:
- Change media_device_init() to return void instead of an error.
  Suggested by Sakari Ailus.
- Remove the error messages when media_device_register() fails.
  Suggested by Sakari Ailus.
- Fix typos in commit message of patch #2. Suggested by Sakari Ailus.

 drivers/media/common/siano/smsdvb-main.c  |  1 +
 drivers/media/media-device.c  | 37 +--
 drivers/media/platform/exynos4-is/media-dev.c | 15 +--
 drivers/media/platform/omap3isp/isp.c | 14 +-
 drivers/media/platform/s3c-camif/camif-core.c | 15 +++
 drivers/media/platform/vsp1/vsp1_drv.c| 12 -
 drivers/media/platform/xilinx/xilinx-vipp.c   | 12 +++--
 drivers/media/usb/au0828/au0828-core.c| 27 ++-
 drivers/media/usb/cx231xx/cx231xx-cards.c | 30 ++
 drivers/media/usb/dvb-usb-v2/dvb_usb_core.c   | 23 +
 drivers/media/usb/dvb-usb/dvb-usb-dvb.c   | 24 +
 drivers/media/usb/siano/smsusb.c  |  5 ++--
 drivers/media/usb/uvc/uvc_driver.c| 10 +---
 include/media/media-device.h  |  2 ++
 14 files changed, 130 insertions(+), 97 deletions(-)

diff --git a/drivers/media/common/siano/smsdvb-main.c 
b/drivers/media/common/siano/smsdvb-main.c
index ab345490a43a..8a1ea2192439 100644
--- a/drivers/media/common/siano/smsdvb-main.c
+++ b/drivers/media/common/siano/smsdvb-main.c
@@ -617,6 +617,7 @@ static void smsdvb_media_device_unregister(struct 
smsdvb_client_t *client)
if (!coredev->media_dev)
return;
media_device_unregister(coredev->media_dev);
+   media_device_cleanup(coredev->media_dev);
kfree(coredev->media_dev);
coredev->media_dev = NULL;
 #endif
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 47d09ffe6a9b..7b1420d2b22e 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -526,7 +526,7 @@ static void media_device_release(struct media_devnode *mdev)
 }
 
 /**
- * media_device_register - register a media device
+ * media_device_init() - initialize a media device
  * @mdev:  The media device
  *
  * The caller is responsible for initializing the media device before
@@ -535,14 +535,8 @@ static void media_device_release(struct media_devnode 
*mdev)
  * - dev must point to the parent device
  * - model must be filled with the device model name
  */
-int __must_check __media_device_register(struct media_device *mdev,
-struct module *owner)
+void media_device_init(struct media_device *mdev)
 {
-   int ret;
-
-   if (WARN_ON(mdev->dev == NULL || mdev->model[0] == 0))
-   return -EINVAL;
-
INIT_LIST_HEAD(>entities);
INIT_LIST_HEAD(>interfaces);
INIT_LIST_HEAD(>pads);
@@ -550,6 +544,33 @@ int __must_check __media_device_register(struct 
media_device *mdev,
spin_lock_init(>lock);
mutex_init(>graph_mutex);
 
+   dev_dbg(mdev->dev, "Media device initialized\n");
+}
+EXPORT_SYMBOL_GPL(media_device_init);
+
+/**
+ * media_device_cleanup() - Cleanup a media device
+ * @mdev:  The media device
+ *
+ */
+void media_device_cleanup(struct media_device *mdev)
+{
+   mutex_destroy(>graph_mutex);
+}
+EXPORT_SYMBOL_GPL(media_device_cleanup);
+
+/**
+ * __media_device_register() - register a media device
+ * @mdev:  The media device
+ * @owner: The module owner
+ *
+ * returns zero on success or a negative error code.
+ */
+int __must_check __media_device_register(struct media_device *mdev,
+struct module *owner)
+{
+   int ret;
+
/* Register the device node. */
mdev->devnode.fops = _device_fops;
mdev->devnode.parent = mdev->dev;
diff --git a/drivers/media/platform/exynos4-is/media-dev.c 

[PATCH v2 0/2] [media] Fix race between graph enumeration and entities registration

2015-09-14 Thread Javier Martinez Canillas
Hello,

The Media Controller framework has an issue in which the media device node
is registered before all the media entities and pads links are created so
if user-space tries to enumerate the graph too early, it may get a partial
graph since not everything has been registered yet.

This series fixes the issue by separate the media device registration from
the initialization so drives can first initialize the media device, create
the graph and then finally register the media device node once is finished.
The solution was suggested by Sakari Ailus.

This is the second version of the series that fixes issues pointed out by
Sakari Ailus. The first version was [0].

Patch #1 adds a check to the media_device_unregister() function to know if
the media device has been registed yet so calling it will be safe and the
cleanup functions of the drivers won't need to be changed in case register
failed.

Patch #2 does the init and registration split, changing all the drivers to
make the change atomic and also adds a cleanup function for media devices.

The patches are on top of Mauro's "[PATCH v8 00/55] MC next generation" [1]
but is not a dependency for that series, it was only be based on that patch
series to avoid conflicts with in-flight patches.

The patches have been tested on an OMAP3 IGEPv2 board that has a OMAP3 ISP
device and an Exynos5800 Chromebook with a built-in UVC camera.

[0]: https://lkml.org/lkml/2015/9/10/311
[1]: http://permalink.gmane.org/gmane.linux.drivers.driver-project.devel/74515

Best regards,
Javier

Changes in v2:
- Reword the documentation for media_device_unregister(). Suggested by Sakari.
- Added Sakari's Acked-by tag for patch #1.
- Change media_device_init() to return void instead of an error.
  Suggested by Sakari Ailus.
- Remove the error messages when media_device_register() fails.
  Suggested by Sakari Ailus.
- Fix typos in commit message of patch #2. Suggested by Sakari Ailus.

Javier Martinez Canillas (2):
  [media] media-device: check before unregister if mdev was registered
  [media] media-device: split media initialization and registration

 drivers/media/common/siano/smsdvb-main.c  |  1 +
 drivers/media/media-device.c  | 43 ++-
 drivers/media/platform/exynos4-is/media-dev.c | 15 +-
 drivers/media/platform/omap3isp/isp.c | 14 -
 drivers/media/platform/s3c-camif/camif-core.c | 15 ++
 drivers/media/platform/vsp1/vsp1_drv.c| 12 
 drivers/media/platform/xilinx/xilinx-vipp.c   | 12 +++-
 drivers/media/usb/au0828/au0828-core.c| 27 -
 drivers/media/usb/cx231xx/cx231xx-cards.c | 30 +--
 drivers/media/usb/dvb-usb-v2/dvb_usb_core.c   | 23 +++---
 drivers/media/usb/dvb-usb/dvb-usb-dvb.c   | 24 ---
 drivers/media/usb/siano/smsusb.c  |  5 ++--
 drivers/media/usb/uvc/uvc_driver.c| 10 +--
 include/media/media-device.h  |  2 ++
 14 files changed, 136 insertions(+), 97 deletions(-)

-- 
2.4.3

--
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 v2 1/3] sysfs: Support is_visible() on binary attributes

2015-09-14 Thread Emilio López
According to the sysfs header file:

"The returned value will replace static permissions defined in
 struct attribute or struct bin_attribute."

but this isn't the case, as is_visible is only called on struct attribute
only. This patch introduces a new is_bin_visible() function to implement
the same functionality for binary attributes, and updates documentation
accordingly.

Signed-off-by: Emilio López 
---

Changes from v1:
 - Don't overload is_visible, introduce is_bin_visible instead as
   discussed on the list.

 fs/sysfs/group.c  | 17 +++--
 include/linux/sysfs.h | 18 ++
 2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index 39a0199..51b56e6 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -73,13 +73,26 @@ static int create_files(struct kernfs_node *parent, struct 
kobject *kobj,
}
 
if (grp->bin_attrs) {
-   for (bin_attr = grp->bin_attrs; *bin_attr; bin_attr++) {
+   for (i = 0, bin_attr = grp->bin_attrs; *bin_attr; i++, 
bin_attr++) {
+   umode_t mode = (*bin_attr)->attr.mode;
+
if (update)
kernfs_remove_by_name(parent,
(*bin_attr)->attr.name);
+   if (grp->is_bin_visible) {
+   mode = grp->is_bin_visible(kobj, *bin_attr, i);
+   if (!mode)
+   continue;
+   }
+
+   WARN(mode & ~(SYSFS_PREALLOC | 0664),
+"Attribute %s: Invalid permissions 0%o\n",
+(*bin_attr)->attr.name, mode);
+
+   mode &= SYSFS_PREALLOC | 0664;
error = sysfs_add_file_mode_ns(parent,
&(*bin_attr)->attr, true,
-   (*bin_attr)->attr.mode, NULL);
+   mode, NULL);
if (error)
break;
}
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 9f65758..2f66050 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -64,10 +64,18 @@ do {
\
  * a new subdirectory with this name.
  * @is_visible:Optional: Function to return permissions associated 
with an
  * attribute of the group. Will be called repeatedly for each
- * attribute in the group. Only read/write permissions as well as
- * SYSFS_PREALLOC are accepted. Must return 0 if an attribute is
- * not visible. The returned value will replace static permissions
- * defined in struct attribute or struct bin_attribute.
+ * non-binary attribute in the group. Only read/write
+ * permissions as well as SYSFS_PREALLOC are accepted. Must
+ * return 0 if an attribute is not visible. The returned value
+ * will replace static permissions defined in struct attribute.
+ * @is_bin_visible:
+ * Optional: Function to return permissions associated with a
+ * binary attribute of the group. Will be called repeatedly
+ * for each binary attribute in the group. Only read/write
+ * permissions as well as SYSFS_PREALLOC are accepted. Must
+ * return 0 if a binary attribute is not visible. The returned
+ * value will replace static permissions defined in
+ * struct bin_attribute.
  * @attrs: Pointer to NULL terminated list of attributes.
  * @bin_attrs: Pointer to NULL terminated list of binary attributes.
  * Either attrs or bin_attrs or both must be provided.
@@ -76,6 +84,8 @@ struct attribute_group {
const char  *name;
umode_t (*is_visible)(struct kobject *,
  struct attribute *, int);
+   umode_t (*is_bin_visible)(struct kobject *,
+ struct bin_attribute *, int);
struct attribute**attrs;
struct bin_attribute**bin_attrs;
 };
-- 
2.1.4

--
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 v2 1/3] sysfs: Support is_visible() on binary attributes

2015-09-14 Thread Guenter Roeck

On 09/14/2015 05:34 AM, Emilio López wrote:

According to the sysfs header file:

 "The returned value will replace static permissions defined in
  struct attribute or struct bin_attribute."

but this isn't the case, as is_visible is only called on struct attribute
only. This patch introduces a new is_bin_visible() function to implement
the same functionality for binary attributes, and updates documentation
accordingly.

Signed-off-by: Emilio López 


Nitpick below, but otherwise looks ok to me.

Reviewed-by: Guenter Roeck 

Guenter


---

Changes from v1:
  - Don't overload is_visible, introduce is_bin_visible instead as
discussed on the list.

  fs/sysfs/group.c  | 17 +++--
  include/linux/sysfs.h | 18 ++
  2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index 39a0199..51b56e6 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -73,13 +73,26 @@ static int create_files(struct kernfs_node *parent, struct 
kobject *kobj,
}

if (grp->bin_attrs) {
-   for (bin_attr = grp->bin_attrs; *bin_attr; bin_attr++) {
+   for (i = 0, bin_attr = grp->bin_attrs; *bin_attr; i++, 
bin_attr++) {
+   umode_t mode = (*bin_attr)->attr.mode;
+
if (update)
kernfs_remove_by_name(parent,
(*bin_attr)->attr.name);
+   if (grp->is_bin_visible) {
+   mode = grp->is_bin_visible(kobj, *bin_attr, i);
+   if (!mode)
+   continue;
+   }
+
+   WARN(mode & ~(SYSFS_PREALLOC | 0664),
+"Attribute %s: Invalid permissions 0%o\n",
+(*bin_attr)->attr.name, mode);
+
+   mode &= SYSFS_PREALLOC | 0664;


Strictly speaking, the mode validation for binary attributes is new and 
logically
separate. Should it be mentioned in the commit log, or even be a separate patch 
?


error = sysfs_add_file_mode_ns(parent,
&(*bin_attr)->attr, true,
-   (*bin_attr)->attr.mode, NULL);
+   mode, NULL);
if (error)
break;
}
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 9f65758..2f66050 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -64,10 +64,18 @@ do {
\
   *a new subdirectory with this name.
   * @is_visible:   Optional: Function to return permissions associated 
with an
   *attribute of the group. Will be called repeatedly for each
- * attribute in the group. Only read/write permissions as well as
- * SYSFS_PREALLOC are accepted. Must return 0 if an attribute is
- * not visible. The returned value will replace static permissions
- * defined in struct attribute or struct bin_attribute.
+ * non-binary attribute in the group. Only read/write
+ * permissions as well as SYSFS_PREALLOC are accepted. Must
+ * return 0 if an attribute is not visible. The returned value
+ * will replace static permissions defined in struct attribute.
+ * @is_bin_visible:
+ * Optional: Function to return permissions associated with a
+ * binary attribute of the group. Will be called repeatedly
+ * for each binary attribute in the group. Only read/write
+ * permissions as well as SYSFS_PREALLOC are accepted. Must
+ * return 0 if a binary attribute is not visible. The returned
+ * value will replace static permissions defined in
+ * struct bin_attribute.
   * @attrs:Pointer to NULL terminated list of attributes.
   * @bin_attrs:Pointer to NULL terminated list of binary attributes.
   *Either attrs or bin_attrs or both must be provided.
@@ -76,6 +84,8 @@ struct attribute_group {
const char  *name;
umode_t (*is_visible)(struct kobject *,
  struct attribute *, int);
+   umode_t (*is_bin_visible)(struct kobject *,
+ struct bin_attribute *, int);
struct attribute**attrs;
struct bin_attribute**bin_attrs;
  };



--
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 v2 3/3] ARM: dts: Enable EC vboot context support on Peach boards

2015-09-14 Thread Krzysztof Kozlowski
On 14.09.2015 21:34, Emilio López wrote:
> The Peach boards use the EC to store the vboot context information,
> so add the corresponding properties on the EC node to indicate so.
> 
> Signed-off-by: Emilio López 
> ---
> 
> Changes from v1:
>  - none
> 
>  arch/arm/boot/dts/exynos5420-peach-pit.dts | 1 +
>  arch/arm/boot/dts/exynos5800-peach-pi.dts  | 1 +
>  2 files changed, 2 insertions(+)

Reviewed-by: Krzysztof Kozlowski 

Best regards,
Krzysztof

--
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 v2] ARM: exynos_defconfig: Enable USB Video Class support

2015-09-14 Thread Krzysztof Kozlowski
On 14.09.2015 21:04, Javier Martinez Canillas wrote:
> The Exynos5420 Peach Pit and Exynos5800 Peach Pi boards have a built-in
> Silicon Motion USB UVC WebCam. Enable support for the USB Video Class
> driver and its needed media Kconfig symbols so the camera is supported.
> 
> Signed-off-by: Javier Martinez Canillas 
> 
> ---
> 
> Changes in v2:
> - Enable tristate Kconfig options as module instead of built-in.
>   Suggested by Krzysztof Kozlowski.

Reviewed-by: Krzysztof Kozlowski 

Best regards,
Krzysztof


--
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 0/4] cpufreq-dt: add suspend frequency support

2015-09-14 Thread Krzysztof Kozlowski
On 09.09.2015 10:16, Rafael J. Wysocki wrote:
> On Tuesday, September 08, 2015 06:41:00 PM Bartlomiej Zolnierkiewicz wrote:
>> Hi,
>>
>> This patch series adds suspend frequency support (using opp-v2
>> bindings and suspend-opp functionality) to cpufreq-dt driver and
>> then adds suspend opp for Exynos4412 based boards.
>>
>> This patch series fixes suspend/resume support on Exynos4412
>> based Trats2 board and reboot hang on Exynos4412 based Odroid
>> U3 board.
>>
>> Changes since v4:
>> - removed superfluous CONFIG_PM ifdefs
>> - added Acked-by tag from Krzysztof to patch #4
>> - added Acked-by tag from Viresh to patches #1-3
>>
>> Changes since v3:
>> - fixed dev_pm_opp_get_suspend_opp() locking
>> - shortened variable name in dev_pm_opp_get_suspend_opp()
>> - adjusted cpufreq_generic_suspend() to work with cpufreq-dt
>> - removed no longer needed cpufreq_dt_suspend()
>> - added Acked-by tag from Viresh to patch #4
>>
>> Changes since v2:
>> - rewrote to use suspend-opp functionality
>>
>> Changes since v1:
>> - removed superfluous ";"
>>
>> Depends on:
>> - next-20150902 branch of linux-next kernel tree
> 
> I've queued up [1-3/4] for the next PM pull request.
> 
> The [4/4] has to go in separately through the platform tree.

Dear Rafael,

If you want, the fourth patch can go now through your tree - the late
SoC changes were pulled by Linus. No difference... I can grab it as I
had other DT related fix in queue.

The only important thing is to get entire patchset to 4.3 because it is
a fix for regression introduced in cpufreq for exynos. Do you plan to
send your part in current 4.3 cycle?

Best regards,
Krzysztof

--
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 0/4] cpufreq-dt: add suspend frequency support

2015-09-14 Thread Viresh Kumar
On 14-09-15, 16:08, Krzysztof Kozlowski wrote:
> If you want, the fourth patch can go now through your tree - the late
> SoC changes were pulled by Linus. No difference... I can grab it as I
> had other DT related fix in queue.
> 
> The only important thing is to get entire patchset to 4.3 because it is
> a fix for regression introduced in cpufreq for exynos. Do you plan to
> send your part in current 4.3 cycle?

The first 3 patches are already part for 4.3-rc1 and so you can keep
the DT update in your tree now. :)

-- 
viresh
--
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 0/4] cpufreq-dt: add suspend frequency support

2015-09-14 Thread Krzysztof Kozlowski
On 14.09.2015 16:17, Viresh Kumar wrote:
> On 14-09-15, 16:08, Krzysztof Kozlowski wrote:
>> If you want, the fourth patch can go now through your tree - the late
>> SoC changes were pulled by Linus. No difference... I can grab it as I
>> had other DT related fix in queue.
>>
>> The only important thing is to get entire patchset to 4.3 because it is
>> a fix for regression introduced in cpufreq for exynos. Do you plan to
>> send your part in current 4.3 cycle?
> 
> The first 3 patches are already part for 4.3-rc1 and so you can keep
> the DT update in your tree now. :)

Damn it, I missed it. It solves everything, the fourth patch will go
through platform tree.

Best regards,
Krzysztof

--
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] arm64: dts: Add BUS1 instance pinctrl support

2015-09-14 Thread Krzysztof Kozlowski
On 14.09.2015 15:16, Alim Akhtar wrote:
> Hello,
> 
> On 09/14/2015 11:21 AM, Krzysztof Kozlowski wrote:
>> On 14.09.2015 14:08, Alim Akhtar wrote:
>>> Hi
>>>
>>> On 08/31/2015 11:12 AM, Krzysztof Kozlowski wrote:
 On 28.08.2015 20:25, Alim Akhtar wrote:
> This adds BUS1 instance pinctrl for exynos7 soc.
>
> Signed-off-by: Alim Akhtar 
> ---
>arch/arm64/boot/dts/exynos/exynos7-pinctrl.dtsi |  111
> +++
>arch/arm64/boot/dts/exynos/exynos7.dtsi |7 ++
>2 files changed, 118 insertions(+)

 The "etc1" GPIO in my datasheet is not fully documented but the rest
 looks good:

>>> Ok will send v2 and remove etc1 gpio node.
>>
>> You don't have to. I mentioned it only for reference that I cannot
>> review the etc GPIO node because it is not mentioned in my datasheet.
>> However you may have different (e.g. newer) datasheet and etc1 could be
>> documented there.
>>
> Sorry for delay, I check two versions of the UM and unfortunately both
> show incomplete entries for etc1, my downstream code has these changes
> though.
>> I applied the first version of patch some time ago (your response is
>> after two weeks). Do you want me to replace it with v2?
>>
> Please consider taking my v2 which I just posted.
> Thanks again.

Okay, I'll replace the patch with v2.

Best regards,
Krzysztof

--
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] arm64: dts: Add BUS1 instance pinctrl support

2015-09-14 Thread Alim Akhtar

Hello,

On 09/14/2015 11:21 AM, Krzysztof Kozlowski wrote:

On 14.09.2015 14:08, Alim Akhtar wrote:

Hi

On 08/31/2015 11:12 AM, Krzysztof Kozlowski wrote:

On 28.08.2015 20:25, Alim Akhtar wrote:

This adds BUS1 instance pinctrl for exynos7 soc.

Signed-off-by: Alim Akhtar 
---
   arch/arm64/boot/dts/exynos/exynos7-pinctrl.dtsi |  111
+++
   arch/arm64/boot/dts/exynos/exynos7.dtsi |7 ++
   2 files changed, 118 insertions(+)


The "etc1" GPIO in my datasheet is not fully documented but the rest
looks good:


Ok will send v2 and remove etc1 gpio node.


You don't have to. I mentioned it only for reference that I cannot
review the etc GPIO node because it is not mentioned in my datasheet.
However you may have different (e.g. newer) datasheet and etc1 could be
documented there.

Sorry for delay, I check two versions of the UM and unfortunately both 
show incomplete entries for etc1, my downstream code has these changes 
though.

I applied the first version of patch some time ago (your response is
after two weeks). Do you want me to replace it with v2?


Please consider taking my v2 which I just posted.
Thanks again.

Best regards,
Krzysztof




--
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 v2 2/3] mfd: s2mps11: Add manual shutdown method for Odroid XU3

2015-09-14 Thread Lee Jones
On Sun, 13 Sep 2015, Krzysztof Kozlowski wrote:
> You acked this patch. However finally it did not go through other tree
> so maybe you could pick it up for 4.4?
> 
> If you want I could reabse and resend it.

Yes, please rebase and resend.

> 2015-08-11 19:09 GMT+09:00 Krzysztof Kozlowski :
> >
> > On Odroid XU3 board (with S2MPS11 PMIC) the PWRHOLD bit in CTRL1
> > register must be manually set to 0 before initiating power off sequence.
> >
> > One of usual power down methods for Exynos based devices looks like:
> > 1. PWRHOLD pin of PMIC is connected to PSHOLD of Exynos.
> > 2. Exynos holds up this pin during system operation.
> > 3. ACOKB pin of PMIC is pulled up to VBATT and optionally to pin in
> >other device.
> > 4. When PWRHOLD/PSHOLD goes low, the PMIC will turn off the power if
> >ACOKB goes high.
> >
> > On Odroid XU3 family the difference is in (3) - the ACOKB is grounded.
> > This means that PMIC must manually set PWRHOLD field to low and then
> > wait for signal from Application Processor (the usual change in
> > PWRHOLD/PSHOLD pin will actually cut off the power).
> >
> > The patch adds respective binding allowing Odroid XU3 device to be
> > powered off.
> >
> > Signed-off-by: Krzysztof Kozlowski 
> > Reported-by: Anand Moon 
> > Tested-by: Anand Moon 
> > Reviewed-by: Javier Martinez Canillas 
> > Acked-by: Lee Jones 
> >
> > ---
> >
> > Changes since v1:
> > 1. Split bindings documentation to separate patch (suggested by Lee).
> > 2. Fix additional empty line (suggested by Lee).
> > 3. Add Anand's tested-by, Javier's reviewed-by and Lee's acked-by.
> >
> > Patch is losely based on patch in Hardkernel repository [0] and previous
> > work of Anand Moon [1].
> >
> > [0] 
> > https://github.com/hardkernel/linux/commit/6897e62ba328bd1c8c095d918101863250cd73e7
> > [1] http://www.spinics.net/lists/linux-samsung-soc/msg45959.html
> > ---
> >  drivers/mfd/sec-core.c  | 30 ++
> >  include/linux/mfd/samsung/core.h|  2 ++
> >  include/linux/mfd/samsung/s2mps11.h |  1 +
> >  3 files changed, 33 insertions(+)
> >
> > diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c
> > index d206a3e8fe87..2d1137a7a0ee 100644
> > --- a/drivers/mfd/sec-core.c
> > +++ b/drivers/mfd/sec-core.c
> > @@ -278,6 +278,8 @@ static struct sec_platform_data 
> > *sec_pmic_i2c_parse_dt_pdata(
> >  * not parsed here.
> >  */
> >
> > +   pd->manual_poweroff = of_property_read_bool(dev->of_node,
> > +   
> > "samsung,s2mps11-acokb-ground");
> > return pd;
> >  }
> >  #else
> > @@ -440,6 +442,33 @@ static int sec_pmic_remove(struct i2c_client *i2c)
> > return 0;
> >  }
> >
> > +static void sec_pmic_shutdown(struct i2c_client *i2c)
> > +{
> > +   struct sec_pmic_dev *sec_pmic = i2c_get_clientdata(i2c);
> > +   unsigned int reg, mask;
> > +
> > +   if (!sec_pmic->pdata->manual_poweroff)
> > +   return;
> > +
> > +   switch (sec_pmic->device_type) {
> > +   case S2MPS11X:
> > +   reg = S2MPS11_REG_CTRL1;
> > +   mask = S2MPS11_CTRL1_PWRHOLD_MASK;
> > +   break;
> > +   default:
> > +   /*
> > +* Currently only one board with S2MPS11 needs this, so just
> > +* ignore the rest.
> > +*/
> > +   dev_warn(sec_pmic->dev,
> > +   "Unsupported device %lu for manual power off\n",
> > +   sec_pmic->device_type);
> > +   return;
> > +   }
> > +
> > +   regmap_update_bits(sec_pmic->regmap_pmic, reg, mask, 0);
> > +}
> > +
> >  #ifdef CONFIG_PM_SLEEP
> >  static int sec_pmic_suspend(struct device *dev)
> >  {
> > @@ -491,6 +520,7 @@ static struct i2c_driver sec_pmic_driver = {
> > },
> > .probe = sec_pmic_probe,
> > .remove = sec_pmic_remove,
> > +   .shutdown = sec_pmic_shutdown,
> > .id_table = sec_pmic_id,
> >  };
> >
> > diff --git a/include/linux/mfd/samsung/core.h 
> > b/include/linux/mfd/samsung/core.h
> > index 75115384f3fc..aa78957e092f 100644
> > --- a/include/linux/mfd/samsung/core.h
> > +++ b/include/linux/mfd/samsung/core.h
> > @@ -132,6 +132,8 @@ struct sec_platform_data {
> > int buck2_init;
> > int buck3_init;
> > int buck4_init;
> > +   /* Whether or not manually set PWRHOLD to low during shutdown. */
> > +   boolmanual_poweroff;
> >  };
> >
> >  /**
> > diff --git a/include/linux/mfd/samsung/s2mps11.h 
> > b/include/linux/mfd/samsung/s2mps11.h
> > index 7981a9d77d3f..b288965e8101 100644
> > --- a/include/linux/mfd/samsung/s2mps11.h
> > +++ b/include/linux/mfd/samsung/s2mps11.h

Re: [PATCH] ARM: multi_v7_defconfig: enable usb3503

2015-09-14 Thread Riku Voipio
On 5 June 2015 at 15:45, Arnd Bergmann  wrote:
> On Thursday 04 June 2015 10:47:07 Kevin Hilman wrote:
>>
>> > But I wonder why is not working, shouldn't the driver defer and
>> > be probed again once the PHY driver probe succeeds?
>>
>> Yeah, I'm not sure why that isn't working, and didn't look into it.
>>
>> FWIW, the same problem happens when both are modules.  If you modprobe
>> usb3503 first, then the phy, it doesn't work.  You have to load the phy
>> before the usb3503.

> The driver does not try to get a reference to the phy, and it does
> not return -EPROBE_DEFER in any circumstance, so I assume it just
> runs into an error condition on the first probe and does not
> try again.

> I don't really understand why the driver registers both an i2c_driver
> and a platform_driver, or if that is required, but it may also
> complicate getting deferred probing to work here.

Is someone looking into fixing it? Having to load this as module would
be an inconvenience for me, as I like to boot arndale with nfsroot.
Yet I understand that eventually I'll need to use an initrd - so not a
blocker, just grumpy work.

Riku
--
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