Re: [PATCH v3 1/5] sc_phy:SmartCard(SC) PHY interface to SC controller

2014-05-29 Thread Satish Patel



On 5/29/2014 12:23 AM, Greg KH wrote:

On Wed, May 28, 2014 at 02:27:13PM +0530, Satish Patel wrote:

SmartCard controller uses this interface to communicate with
SmartCard via PHY

Some SmartCard PHY has multiple slots for cards.
This inerface also enables controller to communicate
with one or more SmartCard connected over phy.

interface structure includes following APIs
- set/get config
- activate/deactivate smart card
- warm reset
- register_notify (for card insert/remove/overheat)
- unregister_notify

Signed-off-by: Satish Patel satish.pa...@ti.com
---
  Documentation/sc_phy.txt |  171 ++
  include/linux/sc_phy.h   |  136 
  2 files changed, 307 insertions(+)
  create mode 100644 Documentation/sc_phy.txt
  create mode 100644 include/linux/sc_phy.h


These are .h files, but where is the api functions that use
these structures defined at?

This is like template/wrappers, smart card phy driver will write API 
functions. And smartcard controller will call these functions.
With proposed approach, smartcard controller can communicate with any 
smart card phy (TI/NxP) without change in code. Using DT entry smartcard 
and PHY will gets connected with each other.

Refer diagram given @Documentation/sc_phy.txt.



confused,

greg k-h


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


Re: [PATCH v3 2/5] misc: tda8026: Add NXP TDA8026 PHY driver

2014-05-29 Thread Satish Patel



On 5/29/2014 12:14 AM, Greg KH wrote:

On Wed, May 28, 2014 at 02:27:14PM +0530, Satish Patel wrote:

TDA8026 is a SmartCard PHY from NXP.

The PHY interfaces with the main processor over the
I2C interface and acts as a slave device.

The driver also exposes the phy interface
(defined@include/linux/sc_phy.h) for SmartCard controller.
Controller uses this interface to communicate with smart card
inserted to the phy's slot.

Note: gpio irq is not validated as I do not have device with that.
I have validated interrupt with dedicated interrupt line on my device.

Signed-off-by: Satish Patel satish.pa...@ti.com
---
  Documentation/devicetree/bindings/misc/tda8026.txt |   19 +
  drivers/misc/Kconfig   |7 +
  drivers/misc/Makefile  |1 +
  drivers/misc/tda8026.c | 1258 
  4 files changed, 1285 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/misc/tda8026.txt
  create mode 100644 drivers/misc/tda8026.c

diff --git a/Documentation/devicetree/bindings/misc/tda8026.txt 
b/Documentation/devicetree/bindings/misc/tda8026.txt
new file mode 100644
index 000..f115c9c
--- /dev/null
+++ b/Documentation/devicetree/bindings/misc/tda8026.txt
@@ -0,0 +1,19 @@
+TDA8026 smart card slot interface
+
+This is an i2c based smart card interface device forming the electrical
+interface between a microcontroller and smart cards. This device supports
+asynchronous cards (micro controller-based IC cards) as well as synchronous
+cards (mainly memory cards)
+
+Required properties:
+- compatible: nxp,tda8026
+- shutdown-gpio = GPIO pin mapping for SDWNN pin
+- reg = i2c interface address
+
+
+Example:
+tda8026: tda8026@48 {
+compatible = nxp,tda8026;
+reg = 0x48;
+shutdown-gpio = gpio5 19 GPIO_ACTIVE_HIGH;/* Bank5, pin19 */
+};
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 8baff0e..80b21d7 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -515,6 +515,13 @@ config SRAM
  the genalloc API. It is supposed to be used for small on-chip SRAM
  areas found on many SoCs.

+config NXP_TDA8026_PHY
+tristate NXP PHY Driver for Smart Card PHY
+depends on I2C=y
+help
+  If you say yes here you get support for the TDA8026 Smart card PHY
+ with I2C interface.
+
  source drivers/misc/c2port/Kconfig
  source drivers/misc/eeprom/Kconfig
  source drivers/misc/cb710/Kconfig
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 7eb4b69..f262c0b 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -55,3 +55,4 @@ obj-$(CONFIG_SRAM)+= sram.o
  obj-y += mic/
  obj-$(CONFIG_GENWQE)  += genwqe/
  obj-$(CONFIG_ECHO)+= echo/
+obj-$(CONFIG_NXP_TDA8026_PHY)  += tda8026.o
diff --git a/drivers/misc/tda8026.c b/drivers/misc/tda8026.c
new file mode 100644
index 000..38df33e
--- /dev/null
+++ b/drivers/misc/tda8026.c
@@ -0,0 +1,1258 @@
+/*
+ * tda8026.c - TDA8026 PHY driver for NXP Smart card PHY
+ *
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * 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 version 2.
+ *
+ * This program is distributed as is WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include linux/module.h
+#include linux/moduleparam.h
+#include linux/interrupt.h
+#include linux/init.h
+#include linux/slab.h
+#include linux/gpio.h
+#include linux/i2c.h
+#include linux/mfd/core.h
+#include linux/notifier.h
+#include linux/sc_phy.h
+#include linux/of_gpio.h
+#include linux/of_device.h
+#include linux/delay.h


I think you just broke the build if this driver is enabled now right?

Not good :(
Before sending, I have applied these patches to v3.15-rc7 and build 
with both the option ti-usim  tda8026 as module, as well as part of 
kernel. Any specific tree you would like me to rebase these patches against.





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


Re: [PATCH v3 1/5] sc_phy:SmartCard(SC) PHY interface to SC controller

2014-05-29 Thread Satish Patel



On 5/29/2014 12:14 AM, Greg KH wrote:

On Wed, May 28, 2014 at 02:27:13PM +0530, Satish Patel wrote:

+/**
+ * struct sc_phy - The basic smart card phy structure
+ *
+ * @dev: phy device
+ * @pdata: pointer to phy's private data structure
+ * @set_config: called to set phy's configuration
+ * @get_config: called to get phy's configuration
+ * @activate_card: perform smart card activation
+ * @deactivate_card: perform smart card de-activation
+ * @warm_reset: execute smart card warm reset sequence
+ * @register_card_activity_cb: register call back to phy device.
+ * This call back will be called on card insert or remove event
+ *
+ * smart card controller uses this interface to communicate with
+ * smart card via phy.Some smart card phy has multiple slots for
+ * cards. This inerface also enables controller to communicate with
+ * one or more smart card connected over phy.
+ */
+struct sc_phy {
+   /* phy's device pointer */
+   struct device *dev;


So this is the parent, right?  Why not embed a struct device into this
structure as well, further streaching out the device tree.


Do you mean to use dev-p for pdata ?
I have kept it outside, to give easeness/pragmatic focal for new phy 
driver development. Driver can make this pointer null and use above pointer.

+
+   /* phy's private data */
+   void *pdata;


If you do the above, then this pointer is not needed.



+
+   /* notify data, passed by interface user as a part of
+* register_notify API. Data should be passed back when
+* notification raised to the interface user
+*/
+   void *notify_data;


What makes this different from the pdata?
pdata is phy's private data, while notify_data is something phy will 
send to smart card controller on some event, like card 
remove/insert/timeout etc..




+
+   int (*set_config)(struct sc_phy *phy, u8 slot,
+   enum sc_phy_config attr, int value);
+   int (*get_config)(struct sc_phy *phy, u8 slot, enum
+   sc_phy_config attr);
+   int (*activate_card)(struct sc_phy *phy, u8 slot);
+   int (*deactivate_card)(struct sc_phy *phy, u8 slot);
+   int (*get_syncatr)(struct sc_phy *phy, u8 slot, u8 len, char *atr);
+   int (*warm_reset)(struct sc_phy *phy, u8 slot);
+   int (*register_notify)(struct sc_phy *phy,
+struct notifier_block *nb, void *notify_data);
+   int (*unregister_notify)(struct sc_phy *phy,
+   struct  notifier_block *nb);
+};
+
+#endif /* __SC_PHY_H__ */
--
1.7.9.5

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


Re: [PATCH v3 1/5] sc_phy:SmartCard(SC) PHY interface to SC controller

2014-05-29 Thread Satish Patel



On 5/29/2014 7:17 PM, Rob Herring wrote:

On Thu, May 29, 2014 at 3:34 AM, Satish Patel satish.pa...@ti.com wrote:



On 5/29/2014 12:23 AM, Greg KH wrote:


On Wed, May 28, 2014 at 02:27:13PM +0530, Satish Patel wrote:


SmartCard controller uses this interface to communicate with
SmartCard via PHY

Some SmartCard PHY has multiple slots for cards.
This inerface also enables controller to communicate
with one or more SmartCard connected over phy.

interface structure includes following APIs
- set/get config
- activate/deactivate smart card
- warm reset
- register_notify (for card insert/remove/overheat)
- unregister_notify

Signed-off-by: Satish Patel satish.pa...@ti.com
---
   Documentation/sc_phy.txt |  171
++
   include/linux/sc_phy.h   |  136 
   2 files changed, 307 insertions(+)
   create mode 100644 Documentation/sc_phy.txt
   create mode 100644 include/linux/sc_phy.h



These are .h files, but where is the api functions that use
these structures defined at?


This is like template/wrappers, smart card phy driver will write API
functions. And smartcard controller will call these functions.
With proposed approach, smartcard controller can communicate with any smart
card phy (TI/NxP) without change in code. Using DT entry smartcard and PHY
will gets connected with each other.
Refer diagram given @Documentation/sc_phy.txt.



confused,


I believe the api Greg is wondering about is the notifier which as I
commented is not a good design.

There is now a phy subsystem. I don't know if it has what you need,
but you should look at it to determine if it will work or could be
extended to work.

I have given my comments on notifier, it is required to notify real time 
events like card insert/remove to the smart card controller. As this 
interrupts tied to phy (in case phy is present) not with controller.


Existing phy subsystem does not support generic operations for the phy. 
If at all it adds supports for these, in future I am ok to get align 
with it.



Rob


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


Re: [PATCH v3 3/5] char: ti-usim: Add driver for USIM module on AM43xx

2014-05-29 Thread Satish Patel



On 5/29/2014 9:23 PM, Greg Kroah-Hartman wrote:

On Thu, May 29, 2014 at 03:35:37PM +0530, Satish Patel wrote:

+enum usim_card_mode {
+   USIM_CARD_MODE_ASYNC = 0,   /* asynchronous mode */
+   USIM_CARD_MODE_SYNC_TYPE1,  /* synchronous mode: Type 1 */
+   USIM_CARD_MODE_SYNC_TYPE2,  /* synchronous mode: Type 2 */
+   USIM_CARD_MODE_SYNC_OTHER,  /* Any other synchronous type */
+};
+struct usim_data {
+   int slot;
+   int rxexplen;
+   int txlen;
+   unsigned char apdu[256];
+};


You need to use the proper variable types for a structure that is going
to cross the user/kernel boundry in an ioctl :(
Do you mean to use __u32 instead int ? make use of types defined in 
types.h ? if yes, I will make that change :). Thanks for pointing out.



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


Re: [PATCH v3 1/5] sc_phy:SmartCard(SC) PHY interface to SC controller

2014-05-29 Thread Satish Patel



On 5/29/2014 9:21 PM, Greg KH wrote:

On Thu, May 29, 2014 at 02:26:55PM +0530, Satish Patel wrote:



On 5/29/2014 12:14 AM, Greg KH wrote:

On Wed, May 28, 2014 at 02:27:13PM +0530, Satish Patel wrote:

+/**
+ * struct sc_phy - The basic smart card phy structure
+ *
+ * @dev: phy device
+ * @pdata: pointer to phy's private data structure
+ * @set_config: called to set phy's configuration
+ * @get_config: called to get phy's configuration
+ * @activate_card: perform smart card activation
+ * @deactivate_card: perform smart card de-activation
+ * @warm_reset: execute smart card warm reset sequence
+ * @register_card_activity_cb: register call back to phy device.
+ * This call back will be called on card insert or remove event
+ *
+ * smart card controller uses this interface to communicate with
+ * smart card via phy.Some smart card phy has multiple slots for
+ * cards. This inerface also enables controller to communicate with
+ * one or more smart card connected over phy.
+ */
+struct sc_phy {
+   /* phy's device pointer */
+   struct device *dev;


So this is the parent, right?  Why not embed a struct device into this
structure as well, further streaching out the device tree.


Do you mean to use dev-p for pdata ?


No, use the device itself.


I have kept it outside, to give easeness/pragmatic focal for new phy driver
development. Driver can make this pointer null and use above pointer.


Ick, no, that's not how the driver model works.  Each device in the
system needs a struct device, don't try to chain off of an existing
device like this.  Make it a real one.


+
+   /* phy's private data */
+   void *pdata;


If you do the above, then this pointer is not needed.



+
+   /* notify data, passed by interface user as a part of
+* register_notify API. Data should be passed back when
+* notification raised to the interface user
+*/
+   void *notify_data;


What makes this different from the pdata?

pdata is phy's private data, while notify_data is something phy will send to
smart card controller on some event, like card remove/insert/timeout etc..


That doesn't make much sense to me, why not just put that in the notify
function callback itself?


Little correction over here..
Here is brief flow
USIM(Smart Card Controller) register notification callback to smarcard phy.

usim-phy-register_notify(phy handle, callback fn, notify_data);
notify_data : pass back when callback function will be called by PHY


Smartcard PHY - USIM
blocking_notifier_call_chain(notifier, action, notify_data);

action : card insert/remove/overheat etc..
notify data: USIM data passing back (supplied at the time of cb 
registration)




Please either use the existing phy layer of the kernel, or make a real
subsystem here, don't try to put a tiny shim on top of an existing
struct device for this driver, that's not how subsystems in Linux are
done.

Why I am not using exiting PHY framework ?

We will be more than happy to adapt generic phy if it
includes/add support for smart card requirements like

1) Some smart card phy (TDA8026-NxP) has multiple slots for smart
cards. This interface enables controller to communicate with specific
smart card inserted to the specific phy's slot.
2) Warm reset to smart card inserted to phy slot.
3) Bit banging of smart card pins to support vendor specific memory
cards.
4) Notification of card insert/remove/overheat etc.
5) synchronous and asynchronous modes for smart card transaction




thanks,

greg k-h


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


[PATCH v3 0/5] Smart Card(SC) interface, TI USIM NxP SC phy driver

2014-05-28 Thread Satish Patel
Changes since v2:
* RFC comments are fixed for all 

* ti-usim:
** synchronous card support is added
** Timeout added for ATR 
** BWT configuration
** softreset of IP at initialization added
** PM suspend/resume support added

* sc_phy : sync card support is added
* ARM: dts: AM43xx: fck clock entry is added to usim

v1 cover letter link#
https://lkml.org/lkml/2014/1/6/250

v2 cover letter link#
https://lkml.org/lkml/2014/1/19/168

Satish Patel (5):
  sc_phy:SmartCard(SC) PHY interface to SC controller
  misc: tda8026: Add NXP TDA8026 PHY driver
  char: ti-usim: Add driver for USIM module on AM43xx
  ARM: dts: AM43xx: DT entries added for ti-usim
  ARM: dts: AM43xx-epos-evm: DT entries  for ti-usim and phy

 Documentation/devicetree/bindings/misc/tda8026.txt |   19 +
 .../devicetree/bindings/ti-usim/ti-usim.txt|   32 +
 Documentation/sc_phy.txt   |  171 ++
 arch/arm/boot/dts/am4372.dtsi  |   12 +
 arch/arm/boot/dts/am43x-epos-evm.dts   |   31 +
 drivers/char/Kconfig   |7 +
 drivers/char/Makefile  |1 +
 drivers/char/ti-usim-hw.h  |  864 
 drivers/char/ti-usim.c | 2213 
 drivers/misc/Kconfig   |7 +
 drivers/misc/Makefile  |1 +
 drivers/misc/tda8026.c | 1258 +++
 include/linux/sc_phy.h |  136 ++
 include/linux/ti-usim.h|  111 +
 14 files changed, 4863 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/tda8026.txt
 create mode 100644 Documentation/devicetree/bindings/ti-usim/ti-usim.txt
 create mode 100644 Documentation/sc_phy.txt
 create mode 100644 drivers/char/ti-usim-hw.h
 create mode 100644 drivers/char/ti-usim.c
 create mode 100644 drivers/misc/tda8026.c
 create mode 100644 include/linux/sc_phy.h
 create mode 100644 include/linux/ti-usim.h

-- 
1.7.9.5

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


[PATCH v3 5/5] ARM: dts: AM43xx-epos-evm: DT entries for ti-usim and phy

2014-05-28 Thread Satish Patel
- Board specific DT entries for TI's USIM - smart card controller of AM43xx
platfrom.These entries are used by USIM driver for various configurations.

- Shutdown line of NXP phy is maped to GPIO5. So enabling same to have support
for NXP phy.

- i2c2 pinmux configuration -  NxP tda8026 phy is connected to i2c2 lines

Signed-off-by: Satish Patel satish.pa...@ti.com
---
 arch/arm/boot/dts/am43x-epos-evm.dts |   31 +++
 1 file changed, 31 insertions(+)

diff --git a/arch/arm/boot/dts/am43x-epos-evm.dts 
b/arch/arm/boot/dts/am43x-epos-evm.dts
index 167dbc8..ecc8b1a 100644
--- a/arch/arm/boot/dts/am43x-epos-evm.dts
+++ b/arch/arm/boot/dts/am43x-epos-evm.dts
@@ -115,6 +115,18 @@
;
};
 
+   usim0_default: usim0_default {
+  pinctrl-single,pins = 
+  /* USIM 0 */
+  0x1B4 (SLEWCTRL_FAST | PULL_DISABLE | MUX_MODE8) 
/* CLK0  */
+  0x1B0 (SLEWCTRL_FAST | PULL_DISABLE | MUX_MODE8) 
/* CLK1  */
+  0x1B8 (SLEWCTRL_FAST | INPUT_EN | PULL_DISABLE | 
MUX_MODE8)  /* DATA0 */
+  0x1BC (SLEWCTRL_FAST | INPUT_EN | PULL_DISABLE | 
MUX_MODE8)  /* DATA1 */
+  0x1C8 (SLEWCTRL_FAST | INPUT_EN | PULL_UP | 
MUX_MODE8)   /* IRQn  */
+  ;
+  };
+
+
spi0_pins: pinmux_spi0_pins {
pinctrl-single,pins = 
0x150 (PIN_INPUT | MUX_MODE0)   /* 
spi0_clk.spi0_clk */
@@ -238,10 +250,24 @@
};
 };
 
+usim0 {
+   pinctrl-names = default;
+   pinctrl-0 = usim0_default;
+   phy = tda8026;
+   phy-slots = 1;
+   status = okay;
+};
+
 i2c2 {
pinctrl-names = default;
pinctrl-0 = i2c2_pins;
status = okay;
+   tda8026: tda8026@48 {
+   compatible = nxp,tda8026;
+   reg = 0x48;
+   shutdown-gpio = gpio5 19 GPIO_ACTIVE_HIGH;   /* Bank5, pin19 
*/
+   interrupts = GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH;
+   };
 };
 
 gpio0 {
@@ -260,6 +286,11 @@
status = okay;
 };
 
+gpio5 {
+   status = okay;
+};
+
+
 elm {
status = okay;
 };
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-omap 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 0/5] Smart Card(SC) interface, TI USIM NxP SC phy driver

2014-05-28 Thread Satish Patel



On 5/28/2014 6:11 AM, Greg KH wrote:

On Fri, May 16, 2014 at 09:14:34AM +0530, Satish Patel wrote:


On 1/30/2014 6:35 PM, Greg KH wrote:

On Thu, Jan 30, 2014 at 11:22:48AM +0530, Satish Patel wrote:

On 1/20/2014 10:03 AM, Satish Patel wrote:

Changes from v1:
* RFC(v1) comments are fixed

** removed gpio_to_irq as GPIO controller process  cell from DT and
give it to DT node
** comments on documentation
** few other comments on null checks are resolved

* BWT timing configuration is added to ti-usim driver

v1 cover letter link#
https://lkml.org/lkml/2014/1/6/250

Satish Patel (5):
   sc_phy:SmartCard(SC) PHY interface to SC controller
   misc: tda8026: Add NXP TDA8026 PHY driver
   char: ti-usim: Add driver for USIM module on AM43xx
   ARM: dts: AM43xx: DT entries added for ti-usim
   ARM: dts: AM43xx-epos-evm: DT entries  for ti-usim and phy

  Documentation/devicetree/bindings/misc/tda8026.txt |   19 +
  .../devicetree/bindings/ti-usim/ti-usim.txt|   31 +
  Documentation/sc_phy.txt   |  171 ++
  arch/arm/boot/dts/am4372.dtsi  |   10 +
  arch/arm/boot/dts/am43x-epos-evm.dts   |   43 +
  drivers/char/Kconfig   |7 +
  drivers/char/Makefile  |1 +
  drivers/char/ti-usim-hw.h  |  863 +
  drivers/char/ti-usim.c | 1859 
  drivers/misc/Kconfig   |7 +
  drivers/misc/Makefile  |1 +
  drivers/misc/tda8026.c | 1255 +
  include/linux/sc_phy.h |  132 ++
  include/linux/ti-usim.h|   98 +
  14 files changed, 4497 insertions(+), 0 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/misc/tda8026.txt
  create mode 100644 Documentation/devicetree/bindings/ti-usim/ti-usim.txt
  create mode 100644 Documentation/sc_phy.txt
  create mode 100644 drivers/char/ti-usim-hw.h
  create mode 100644 drivers/char/ti-usim.c
  create mode 100644 drivers/misc/tda8026.c
  create mode 100644 include/linux/sc_phy.h
  create mode 100644 include/linux/ti-usim.h

Any comments on this patch series ?

If not,
Can you accept these patches for next merge window

It's the middle of this merge window, and I can't accept any patches
until after 3.14-rc1 is out, at which point I'll start to work on my
patch backlog.

Are these to be consider for next submission ? Or you want me to start
review cycle one more time.


I don't have them in my queue, so please resend.
I have resent patches for review. could you consider the same for next 
merge window ?



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


[PATCH v3 4/5] ARM: dts: AM43xx: DT entries added for ti-usim

2014-05-28 Thread Satish Patel
SoC specific DT entries added for TI's USIM - smart card controller of AM43xx
platfrom.

Signed-off-by: Satish Patel satish.pa...@ti.com
---
 arch/arm/boot/dts/am4372.dtsi |   12 
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/am4372.dtsi b/arch/arm/boot/dts/am4372.dtsi
index d1f8707..fe830dd 100644
--- a/arch/arm/boot/dts/am4372.dtsi
+++ b/arch/arm/boot/dts/am4372.dtsi
@@ -735,6 +735,18 @@
#size-cells = 1;
status = disabled;
};
+
+   usim0: usim@48034000 {
+   compatible = ti,usim;
+   reg = 0x48034000 0x1000;
+   interrupts = GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH;
+   ti,hwmods = usim0;
+   clocks = usim0_opt_fck, usim0_opt_fck32,
+dpll_per_m2_div4_ck;
+   clock-names = opt_fck, opt_fck32, fck;
+   status = disabled;
+   };
+
};
 };
 
-- 
1.7.9.5

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


[PATCH v3 2/5] misc: tda8026: Add NXP TDA8026 PHY driver

2014-05-28 Thread Satish Patel
TDA8026 is a SmartCard PHY from NXP.

The PHY interfaces with the main processor over the
I2C interface and acts as a slave device.

The driver also exposes the phy interface
(defined@include/linux/sc_phy.h) for SmartCard controller.
Controller uses this interface to communicate with smart card
inserted to the phy's slot.

Note: gpio irq is not validated as I do not have device with that.
I have validated interrupt with dedicated interrupt line on my device.

Signed-off-by: Satish Patel satish.pa...@ti.com
---
 Documentation/devicetree/bindings/misc/tda8026.txt |   19 +
 drivers/misc/Kconfig   |7 +
 drivers/misc/Makefile  |1 +
 drivers/misc/tda8026.c | 1258 
 4 files changed, 1285 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/tda8026.txt
 create mode 100644 drivers/misc/tda8026.c

diff --git a/Documentation/devicetree/bindings/misc/tda8026.txt 
b/Documentation/devicetree/bindings/misc/tda8026.txt
new file mode 100644
index 000..f115c9c
--- /dev/null
+++ b/Documentation/devicetree/bindings/misc/tda8026.txt
@@ -0,0 +1,19 @@
+TDA8026 smart card slot interface
+
+This is an i2c based smart card interface device forming the electrical
+interface between a microcontroller and smart cards. This device supports
+asynchronous cards (micro controller-based IC cards) as well as synchronous
+cards (mainly memory cards)
+
+Required properties:
+- compatible: nxp,tda8026
+- shutdown-gpio = GPIO pin mapping for SDWNN pin
+- reg = i2c interface address
+
+
+Example:
+tda8026: tda8026@48 {
+compatible = nxp,tda8026;
+reg = 0x48;
+shutdown-gpio = gpio5 19 GPIO_ACTIVE_HIGH;/* Bank5, pin19 */
+};
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 8baff0e..80b21d7 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -515,6 +515,13 @@ config SRAM
  the genalloc API. It is supposed to be used for small on-chip SRAM
  areas found on many SoCs.
 
+config NXP_TDA8026_PHY
+tristate NXP PHY Driver for Smart Card PHY
+depends on I2C=y
+help
+  If you say yes here you get support for the TDA8026 Smart card PHY
+ with I2C interface.
+
 source drivers/misc/c2port/Kconfig
 source drivers/misc/eeprom/Kconfig
 source drivers/misc/cb710/Kconfig
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 7eb4b69..f262c0b 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -55,3 +55,4 @@ obj-$(CONFIG_SRAM)+= sram.o
 obj-y  += mic/
 obj-$(CONFIG_GENWQE)   += genwqe/
 obj-$(CONFIG_ECHO) += echo/
+obj-$(CONFIG_NXP_TDA8026_PHY)  += tda8026.o
diff --git a/drivers/misc/tda8026.c b/drivers/misc/tda8026.c
new file mode 100644
index 000..38df33e
--- /dev/null
+++ b/drivers/misc/tda8026.c
@@ -0,0 +1,1258 @@
+/*
+ * tda8026.c - TDA8026 PHY driver for NXP Smart card PHY
+ *
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * 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 version 2.
+ *
+ * This program is distributed as is WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include linux/module.h
+#include linux/moduleparam.h
+#include linux/interrupt.h
+#include linux/init.h
+#include linux/slab.h
+#include linux/gpio.h
+#include linux/i2c.h
+#include linux/mfd/core.h
+#include linux/notifier.h
+#include linux/sc_phy.h
+#include linux/of_gpio.h
+#include linux/of_device.h
+#include linux/delay.h
+
+#define TDA8026_MAX_SLOTS  (5)
+#define TDA8026_NUM_SAM_SLOTS  (4)
+#define TDA8026_USERCARD_SLOT  (1)
+
+#define TDA8026_CSB_ADDR   (0x24)
+#define TDA8026_REG0_ADDR  (0x20)
+#define TDA8026_REG1_ADDR  (0x21)
+#define TDA8026_SLEWRATE_ADDR  (0x20)
+#define TDA8026_PRODVER_ADDR   (0x20)
+#define TDA8026_INTSTAT_ADDR   (0x21)
+
+#define TDA8026_PHY_PRODUCT_VERSION(0xC2)
+
+/* CSB register values */
+#define TDA8026_CSB_PV_INTSTAT_VAL (0x0)
+#define TDA8026_CSB_SLEWRATE_VAL   (0x6)
+
+/* Slot REG0 read mode bit fields */
+#define TDA8026_REG0_ACTIVE_MASK   (0x80)
+#define TDA8026_REG0_EARLY_MASK(0x40)
+#define TDA8026_REG0_MUTE_MASK (0x20)
+#define TDA8026_REG0_PROT_MASK (0x10)
+#define TDA8026_REG0_SUPL_MASK (0x08)
+#define TDA8026_REG0_CLKSW_MASK(0x04)
+#define TDA8026_REG0_PREL_MASK (0x02)
+#define TDA8026_REG0_PRES_MASK (0x01)
+
+/* Slot REG0 write mode bit fields */
+#define TDA8026_REG0_VCC1V8_MASK

[PATCH v3 1/5] sc_phy:SmartCard(SC) PHY interface to SC controller

2014-05-28 Thread Satish Patel
SmartCard controller uses this interface to communicate with
SmartCard via PHY

Some SmartCard PHY has multiple slots for cards.
This inerface also enables controller to communicate
with one or more SmartCard connected over phy.

interface structure includes following APIs
- set/get config
- activate/deactivate smart card
- warm reset
- register_notify (for card insert/remove/overheat)
- unregister_notify

Signed-off-by: Satish Patel satish.pa...@ti.com
---
 Documentation/sc_phy.txt |  171 ++
 include/linux/sc_phy.h   |  136 
 2 files changed, 307 insertions(+)
 create mode 100644 Documentation/sc_phy.txt
 create mode 100644 include/linux/sc_phy.h

diff --git a/Documentation/sc_phy.txt b/Documentation/sc_phy.txt
new file mode 100644
index 000..d610e26
--- /dev/null
+++ b/Documentation/sc_phy.txt
@@ -0,0 +1,171 @@
+   SmartCard PHY Interface
+   Satish Patel satish.pa...@ti.com
+
+This document explains the SmartCard interface between SmartCard
+controller and SmartCard phy. Document also describes how-to-use.
+
+1. Why SmartCard PHY Interface?
+
+The use of smartcard is increasing in embedded industry. As smartcard
+not only prevent duplication but also, brings key based authentication
+flow into picture.
+
+SmartCard standards like EMV(EuroPay-Mastercard-Visa) are becoming
+mandatory for payment terminals.
+
+Till date, most of the SmartCard readers are based on USB serial
+interface. Which drives its logic within firmware lies on device.
+Few are based on FPGA solutions. But now SoCs are coming up with
+inbuilt smartcard controller. e.g. TI-AM43x
+
+Role of SmartCard controller and SmartCard phy:
+
+Smartcard Phy:
+Forms electrical interface between controller and SmartCard. Phy
+enables access to more than one smartcard and in addition it provides
+fast deactivation logic when card gets removed from the slot. It can
+also generate the signals like card insert/remove/overheat etc.
+
+Smartcard Controller:
+In built mechanism to meet EMV L1 specification (e.g. T=0, T=1
+protocol timings, ATR timeout etc..) for SmartCard transaction. In
+addition to this, it has FIFO to store tx/rx bytes, internal state
+machine for ATR, Tx/Rx, Synchronous/Asynchronous mode, timing
+counters etc..
+
+Controller can also have direct interface through which SmartCard
+can be connected without phy.
+
+Below is the brief of SmartCard block diagram from user to h/w
+layer.
+
+
+---
+|PC/SC App|
+---
+--- ---
+|PC/SC F/W| | Visa APP|
+--- ---
+--- 
+|IFD Hand.| | EMV L1/L2|| Test App |
+--- 
+User Space
+
+
+-
+|   SmartCard Controller Driver|
+-
+ | |
+ | |
+-  |
+| Phy Driver | |
+-  |
+ | |
+Kernel Space | |
+
+ | |
+   -  
+   | PHY   |  |Controller IP |
+   -  
+|   |
+
+|   |
+   ___
+   |||
+ VISA card   Master Card  Custom Card
+
+
+At present in Linux there is no public interface exist which acts as
+bridge between controller and phy. Mostly vendors uses proprietary
+solution in such cases.
+
+2. Introduction to SmartCard PHY interface
+
+SmartCard PHY interface that exposes phy's capabilities to the smart
+card controller. SmartCard controller uses this interface to
+communicate with SmartCard via phy.
+
+Such capabilities are:
+1) Some SmartCard phy (e.g. TDA8026-NxP) has multiple slots for smart
+cards. This interface enables controller to communicate with specific
+SmartCard inserted to the specific phy's slot.
+
+2) Warm reset to SmartCard inserted to phy slot.
+
+3) Bit banging of SmartCard pins to support vedor specific memory
+cards. Mostly when it comes to sychorous SmartCard
+
+4) Notification of card insert/remove/overheat etc.
+
+
+3. How to use
+
+SmartCard PHY:
+The SmartCard PHY driver, who wants to be interfaced with SmartCard
+controller require to follow below step
+
+- include sc_phy.h
+
+- use sc_phy structure as driver(client) data. PHY

Re: [PATCH v2 0/5] Smart Card(SC) interface, TI USIM NxP SC phy driver

2014-05-15 Thread Satish Patel


On 1/30/2014 6:35 PM, Greg KH wrote:

On Thu, Jan 30, 2014 at 11:22:48AM +0530, Satish Patel wrote:

On 1/20/2014 10:03 AM, Satish Patel wrote:

Changes from v1:
* RFC(v1) comments are fixed

** removed gpio_to_irq as GPIO controller process  cell from DT and
give it to DT node
** comments on documentation
** few other comments on null checks are resolved

* BWT timing configuration is added to ti-usim driver

v1 cover letter link#
https://lkml.org/lkml/2014/1/6/250

Satish Patel (5):
   sc_phy:SmartCard(SC) PHY interface to SC controller
   misc: tda8026: Add NXP TDA8026 PHY driver
   char: ti-usim: Add driver for USIM module on AM43xx
   ARM: dts: AM43xx: DT entries added for ti-usim
   ARM: dts: AM43xx-epos-evm: DT entries  for ti-usim and phy

  Documentation/devicetree/bindings/misc/tda8026.txt |   19 +
  .../devicetree/bindings/ti-usim/ti-usim.txt|   31 +
  Documentation/sc_phy.txt   |  171 ++
  arch/arm/boot/dts/am4372.dtsi  |   10 +
  arch/arm/boot/dts/am43x-epos-evm.dts   |   43 +
  drivers/char/Kconfig   |7 +
  drivers/char/Makefile  |1 +
  drivers/char/ti-usim-hw.h  |  863 +
  drivers/char/ti-usim.c | 1859 
  drivers/misc/Kconfig   |7 +
  drivers/misc/Makefile  |1 +
  drivers/misc/tda8026.c | 1255 +
  include/linux/sc_phy.h |  132 ++
  include/linux/ti-usim.h|   98 +
  14 files changed, 4497 insertions(+), 0 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/misc/tda8026.txt
  create mode 100644 Documentation/devicetree/bindings/ti-usim/ti-usim.txt
  create mode 100644 Documentation/sc_phy.txt
  create mode 100644 drivers/char/ti-usim-hw.h
  create mode 100644 drivers/char/ti-usim.c
  create mode 100644 drivers/misc/tda8026.c
  create mode 100644 include/linux/sc_phy.h
  create mode 100644 include/linux/ti-usim.h

Any comments on this patch series ?

If not,
Can you accept these patches for next merge window

It's the middle of this merge window, and I can't accept any patches
until after 3.14-rc1 is out, at which point I'll start to work on my
patch backlog.
Are these to be consider for next submission ? Or you want me to start 
review cycle one more time.

thanks,

greg k-h


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


Re: [RFC PATCH v1 0/2] clock and HWMOD changes for USIM module

2014-03-02 Thread Satish Patel


On 3/1/2014 3:29 AM, Tony Lindgren wrote:
 * Satish Patel satish.pa...@ti.com [140109 00:13]:


 On 1/6/2014 5:42 PM, Satish Patel wrote:
 Patch set includes clock and HWMOD entries for AM43x's USIM modoule.

 Note: I am in process of mainlining usim driver.

 Satish Patel (2):
   ARM: dts: AM43xx-clocks: Entries added for ti-usim
   ARM: OMAP: AM43xx: HWMOD changes added for ti-usim


 Tony,

 Can you pull in these patches if there are no comments?
 
 Would like to see acks from Benoit/Tero/Paul first.
 
Benoit/Tero/Paul:
Can you please review and ack this patch series,
so that tony can pick it up.

Thanks
satish
 Regards,
 
 Tony
 
--
To unsubscribe from this list: send the line unsubscribe linux-omap 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/5] char: ti-usim: Add driver for USIM module on AM43xx

2014-02-05 Thread Satish Patel


On 2/4/2014 6:49 PM, Roger Quadros wrote:
 Hi Satish,
 
 On 01/20/2014 06:33 AM, Satish Patel wrote:
 TI-USIM driver is a platform driver that provides a character
 driver interface to user applications.

 It allows user applications to call IOCTL's to
 perform smart card operations.

 Driver currently supports
 - ATR
 - T=0  T=1 protocol
 - clock stop mode
 - smart card clock configuration
 - Tx/Rx application data units (APDU) to smart card
 - Interface to PHY using DT  phy interface

 Validation is done with ACOS3 smart cards

 Signed-off-by: Satish Patel satish.pa...@ti.com
 ---
  .../devicetree/bindings/ti-usim/ti-usim.txt|   31 +
  drivers/char/Kconfig   |7 +
  drivers/char/Makefile  |1 +
  drivers/char/ti-usim-hw.h  |  863 +
  drivers/char/ti-usim.c | 1859 
 
 
 ti-usim.c is a very large driver that does everything but looks like limited 
 to TI hardware.
 How about splitting it into generic stuff and hw specific glue logic so that 
 most of the generic stuff
 could be used by different hardware types.
 
Two things over here
- First interface between user application and smartcard controller
driver. There is already an open source f/w in user space called pcsc
exists for this.

- Second communication between smartcard controller and smartcard phy. I
have introduce lite interface called sc_phy which covers generic stuff
between controller and phy.


  include/linux/ti-usim.h|   98 +
  6 files changed, 2859 insertions(+), 0 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/ti-usim/ti-usim.txt
  create mode 100644 drivers/char/ti-usim-hw.h
  create mode 100644 drivers/char/ti-usim.c
  create mode 100644 include/linux/ti-usim.h

 
 cheers,
 -roger
 
--
To unsubscribe from this list: send the line unsubscribe linux-omap 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 0/5] Smart Card(SC) interface, TI USIM NxP SC phy driver

2014-01-29 Thread Satish Patel

On 1/20/2014 10:03 AM, Satish Patel wrote:
 Changes from v1:
 * RFC(v1) comments are fixed

 ** removed gpio_to_irq as GPIO controller process  cell from DT and
 give it to DT node
 ** comments on documentation
 ** few other comments on null checks are resolved

 * BWT timing configuration is added to ti-usim driver

 v1 cover letter link#
 https://lkml.org/lkml/2014/1/6/250

 Satish Patel (5):
   sc_phy:SmartCard(SC) PHY interface to SC controller
   misc: tda8026: Add NXP TDA8026 PHY driver
   char: ti-usim: Add driver for USIM module on AM43xx
   ARM: dts: AM43xx: DT entries added for ti-usim
   ARM: dts: AM43xx-epos-evm: DT entries  for ti-usim and phy

  Documentation/devicetree/bindings/misc/tda8026.txt |   19 +
  .../devicetree/bindings/ti-usim/ti-usim.txt|   31 +
  Documentation/sc_phy.txt   |  171 ++
  arch/arm/boot/dts/am4372.dtsi  |   10 +
  arch/arm/boot/dts/am43x-epos-evm.dts   |   43 +
  drivers/char/Kconfig   |7 +
  drivers/char/Makefile  |1 +
  drivers/char/ti-usim-hw.h  |  863 +
  drivers/char/ti-usim.c | 1859 
 
  drivers/misc/Kconfig   |7 +
  drivers/misc/Makefile  |1 +
  drivers/misc/tda8026.c | 1255 +
  include/linux/sc_phy.h |  132 ++
  include/linux/ti-usim.h|   98 +
  14 files changed, 4497 insertions(+), 0 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/misc/tda8026.txt
  create mode 100644 Documentation/devicetree/bindings/ti-usim/ti-usim.txt
  create mode 100644 Documentation/sc_phy.txt
  create mode 100644 drivers/char/ti-usim-hw.h
  create mode 100644 drivers/char/ti-usim.c
  create mode 100644 drivers/misc/tda8026.c
  create mode 100644 include/linux/sc_phy.h
  create mode 100644 include/linux/ti-usim.h
Any comments on this patch series ?

If not,
Can you accept these patches for next merge window

Thanks
Satish




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


[PATCH v2 5/5] ARM: dts: AM43xx-epos-evm: DT entries for ti-usim and phy

2014-01-19 Thread Satish Patel
- Board specific DT entries for TI's USIM - smart card controller of AM43xx
platfrom.These entries are used by USIM driver for various configurations.

- Shutdown line of NXP phy is maped to GPIO5. So enabling same to have support
for NXP phy.

- i2c2 pinmux configuration -  NxP tda8026 phy is connected to i2c2 lines

Signed-off-by: Satish Patel satish.pa...@ti.com
---
 arch/arm/boot/dts/am43x-epos-evm.dts |   43 ++
 1 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/am43x-epos-evm.dts 
b/arch/arm/boot/dts/am43x-epos-evm.dts
index fbf9c4c..38ef2b8 100644
--- a/arch/arm/boot/dts/am43x-epos-evm.dts
+++ b/arch/arm/boot/dts/am43x-epos-evm.dts
@@ -79,6 +79,24 @@
0x18c (PIN_INPUT_PULLUP | SLEWCTRL_FAST | 
MUX_MODE0)/* i2c0_scl.i2c0_scl */
;
};
+
+   i2c2_pins: pinmux_i2c2_pins {
+  pinctrl-single,pins = 
+  0x1c0 (PIN_INPUT_PULLUP | SLEWCTRL_FAST | MUX_MODE8) 
   /* i2c2_sda.i2c2_sda */
+  0x1c4 (PIN_INPUT_PULLUP | SLEWCTRL_FAST | MUX_MODE8) 
   /* i2c2_scl.i2c2_scl */
+  ;
+   };
+
+   usim0_default: usim0_default {
+  pinctrl-single,pins = 
+  /* USIM 0 */
+  0x1B4 (SLEWCTRL_FAST | PULL_DISABLE | MUX_MODE8) 
/* CLK0  */
+  0x1B0 (SLEWCTRL_FAST | PULL_DISABLE | MUX_MODE8) 
/* CLK1  */
+  0x1B8 (SLEWCTRL_FAST | INPUT_EN | PULL_DISABLE | 
MUX_MODE8)  /* DATA0 */
+  0x1BC (SLEWCTRL_FAST | INPUT_EN | PULL_DISABLE | 
MUX_MODE8)  /* DATA1 */
+  0x1C8 (SLEWCTRL_FAST | INPUT_EN | PULL_UP | 
MUX_MODE8)   /* IRQn  */
+  ;
+   };
};
 
matrix_keypad: matrix_keypad@0 {
@@ -169,6 +187,27 @@
};
 };
 
+usim0 {
+   pinctrl-names = default;
+   pinctrl-0 = usim0_default;
+   phy = tda8026;
+   phy-slots = 1;
+   status = okay;
+};
+
+i2c2 {
+   pinctrl-names = default;
+   pinctrl-0 = i2c2_pins;
+   status = okay;
+
+   tda8026: tda8026@48 {
+   compatible = nxp,tda8026;
+   reg = 0x48;
+   shutdown-gpio = gpio5 19 GPIO_ACTIVE_HIGH;   /* Bank5, pin19 
*/
+   interrupts = GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH;
+   };
+};
+
 gpio0 {
status = okay;
 };
@@ -184,3 +223,7 @@
 gpio3 {
status = okay;
 };
+
+gpio5 {
+   status = okay;
+};
-- 
1.7.1

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


[PATCH v2 0/5] Smart Card(SC) interface, TI USIM NxP SC phy driver

2014-01-19 Thread Satish Patel
Changes from v1:
* RFC(v1) comments are fixed

** removed gpio_to_irq as GPIO controller process  cell from DT and
give it to DT node
** comments on documentation
** few other comments on null checks are resolved

* BWT timing configuration is added to ti-usim driver

v1 cover letter link#
https://lkml.org/lkml/2014/1/6/250

Satish Patel (5):
  sc_phy:SmartCard(SC) PHY interface to SC controller
  misc: tda8026: Add NXP TDA8026 PHY driver
  char: ti-usim: Add driver for USIM module on AM43xx
  ARM: dts: AM43xx: DT entries added for ti-usim
  ARM: dts: AM43xx-epos-evm: DT entries  for ti-usim and phy

 Documentation/devicetree/bindings/misc/tda8026.txt |   19 +
 .../devicetree/bindings/ti-usim/ti-usim.txt|   31 +
 Documentation/sc_phy.txt   |  171 ++
 arch/arm/boot/dts/am4372.dtsi  |   10 +
 arch/arm/boot/dts/am43x-epos-evm.dts   |   43 +
 drivers/char/Kconfig   |7 +
 drivers/char/Makefile  |1 +
 drivers/char/ti-usim-hw.h  |  863 +
 drivers/char/ti-usim.c | 1859 
 drivers/misc/Kconfig   |7 +
 drivers/misc/Makefile  |1 +
 drivers/misc/tda8026.c | 1255 +
 include/linux/sc_phy.h |  132 ++
 include/linux/ti-usim.h|   98 +
 14 files changed, 4497 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/misc/tda8026.txt
 create mode 100644 Documentation/devicetree/bindings/ti-usim/ti-usim.txt
 create mode 100644 Documentation/sc_phy.txt
 create mode 100644 drivers/char/ti-usim-hw.h
 create mode 100644 drivers/char/ti-usim.c
 create mode 100644 drivers/misc/tda8026.c
 create mode 100644 include/linux/sc_phy.h
 create mode 100644 include/linux/ti-usim.h

--
To unsubscribe from this list: send the line unsubscribe linux-omap 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/5] sc_phy:SmartCard(SC) PHY interface to SC controller

2014-01-19 Thread Satish Patel
SmartCard controller uses this interface to communicate with
SmartCard via PHY

Some SmartCard PHY has multiple slots for cards.
This inerface also enables controller to communicate
with one or more SmartCard connected over phy.

interface structure includes following APIs
- set/get config
- activate/deactivate smart card
- warm reset
- register_notify (for card insert/remove/overheat)
- unregister_notify

Signed-off-by: Satish Patel satish.pa...@ti.com
---
 Documentation/sc_phy.txt |  171 ++
 include/linux/sc_phy.h   |  132 +++
 2 files changed, 303 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/sc_phy.txt
 create mode 100644 include/linux/sc_phy.h

diff --git a/Documentation/sc_phy.txt b/Documentation/sc_phy.txt
new file mode 100644
index 000..d610e26
--- /dev/null
+++ b/Documentation/sc_phy.txt
@@ -0,0 +1,171 @@
+   SmartCard PHY Interface
+   Satish Patel satish.pa...@ti.com
+
+This document explains the SmartCard interface between SmartCard
+controller and SmartCard phy. Document also describes how-to-use.
+
+1. Why SmartCard PHY Interface?
+
+The use of smartcard is increasing in embedded industry. As smartcard
+not only prevent duplication but also, brings key based authentication
+flow into picture.
+
+SmartCard standards like EMV(EuroPay-Mastercard-Visa) are becoming
+mandatory for payment terminals.
+
+Till date, most of the SmartCard readers are based on USB serial
+interface. Which drives its logic within firmware lies on device.
+Few are based on FPGA solutions. But now SoCs are coming up with
+inbuilt smartcard controller. e.g. TI-AM43x
+
+Role of SmartCard controller and SmartCard phy:
+
+Smartcard Phy:
+Forms electrical interface between controller and SmartCard. Phy
+enables access to more than one smartcard and in addition it provides
+fast deactivation logic when card gets removed from the slot. It can
+also generate the signals like card insert/remove/overheat etc.
+
+Smartcard Controller:
+In built mechanism to meet EMV L1 specification (e.g. T=0, T=1
+protocol timings, ATR timeout etc..) for SmartCard transaction. In
+addition to this, it has FIFO to store tx/rx bytes, internal state
+machine for ATR, Tx/Rx, Synchronous/Asynchronous mode, timing
+counters etc..
+
+Controller can also have direct interface through which SmartCard
+can be connected without phy.
+
+Below is the brief of SmartCard block diagram from user to h/w
+layer.
+
+
+---
+|PC/SC App|
+---
+--- ---
+|PC/SC F/W| | Visa APP|
+--- ---
+--- 
+|IFD Hand.| | EMV L1/L2|| Test App |
+--- 
+User Space
+
+
+-
+|   SmartCard Controller Driver|
+-
+ | |
+ | |
+-  |
+| Phy Driver | |
+-  |
+ | |
+Kernel Space | |
+
+ | |
+   -  
+   | PHY   |  |Controller IP |
+   -  
+|   |
+
+|   |
+   ___
+   |||
+ VISA card   Master Card  Custom Card
+
+
+At present in Linux there is no public interface exist which acts as
+bridge between controller and phy. Mostly vendors uses proprietary
+solution in such cases.
+
+2. Introduction to SmartCard PHY interface
+
+SmartCard PHY interface that exposes phy's capabilities to the smart
+card controller. SmartCard controller uses this interface to
+communicate with SmartCard via phy.
+
+Such capabilities are:
+1) Some SmartCard phy (e.g. TDA8026-NxP) has multiple slots for smart
+cards. This interface enables controller to communicate with specific
+SmartCard inserted to the specific phy's slot.
+
+2) Warm reset to SmartCard inserted to phy slot.
+
+3) Bit banging of SmartCard pins to support vedor specific memory
+cards. Mostly when it comes to sychorous SmartCard
+
+4) Notification of card insert/remove/overheat etc.
+
+
+3. How to use
+
+SmartCard PHY:
+The SmartCard PHY driver, who wants to be interfaced with SmartCard
+controller require to follow below step
+
+- include sc_phy.h
+
+- use sc_phy structure as driver(client

[PATCH v2 4/5] ARM: dts: AM43xx: DT entries added for ti-usim

2014-01-19 Thread Satish Patel
SoC specific DT entries added for TI's USIM - smart card controller of AM43xx
platfrom.

Signed-off-by: Satish Patel satish.pa...@ti.com
---
 arch/arm/boot/dts/am4372.dtsi |   10 ++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/am4372.dtsi b/arch/arm/boot/dts/am4372.dtsi
index 974d103..7ed1cd1 100644
--- a/arch/arm/boot/dts/am4372.dtsi
+++ b/arch/arm/boot/dts/am4372.dtsi
@@ -663,5 +663,15 @@
   edma 11;
dma-names = tx, rx;
};
+
+   usim0: usim@48034000 {
+   compatible = ti,usim;
+   reg = 0x48034000 0x1000;
+   interrupts = GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH;
+   ti,hwmods = usim0;
+   clocks = usim0_opt_fck, usim0_opt_fck32;
+   clock-names = opt_fck, opt_fck32;
+   status = disabled;
+   };
};
 };
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-omap 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/5] misc: tda8026: Add NXP TDA8026 PHY driver

2014-01-19 Thread Satish Patel
TDA8026 is a SmartCard PHY from NXP.

The PHY interfaces with the main processor over the
I2C interface and acts as a slave device.

The driver also exposes the phy interface
(defined@include/linux/sc_phy.h) for SmartCard controller.
Controller uses this interface to communicate with smart card
inserted to the phy's slot.

Note: gpio irq is not validated as I do not have device with that.
I have validated interrupt with dedicated interrupt line on my device.

Signed-off-by: Satish Patel satish.pa...@ti.com
---
 Documentation/devicetree/bindings/misc/tda8026.txt |   19 +
 drivers/misc/Kconfig   |7 +
 drivers/misc/Makefile  |1 +
 drivers/misc/tda8026.c | 1255 
 4 files changed, 1282 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/misc/tda8026.txt
 create mode 100644 drivers/misc/tda8026.c

diff --git a/Documentation/devicetree/bindings/misc/tda8026.txt 
b/Documentation/devicetree/bindings/misc/tda8026.txt
new file mode 100644
index 000..f115c9c
--- /dev/null
+++ b/Documentation/devicetree/bindings/misc/tda8026.txt
@@ -0,0 +1,19 @@
+TDA8026 smart card slot interface
+
+This is an i2c based smart card interface device forming the electrical
+interface between a microcontroller and smart cards. This device supports
+asynchronous cards (micro controller-based IC cards) as well as synchronous
+cards (mainly memory cards)
+
+Required properties:
+- compatible: nxp,tda8026
+- shutdown-gpio = GPIO pin mapping for SDWNN pin
+- reg = i2c interface address
+
+
+Example:
+tda8026: tda8026@48 {
+compatible = nxp,tda8026;
+reg = 0x48;
+shutdown-gpio = gpio5 19 GPIO_ACTIVE_HIGH;/* Bank5, pin19 */
+};
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index a3e291d..bb94a6f 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -515,6 +515,13 @@ config SRAM
  the genalloc API. It is supposed to be used for small on-chip SRAM
  areas found on many SoCs.
 
+config NXP_TDA8026_PHY
+tristate NXP PHY Driver for Smart Card PHY
+depends on I2C=y
+help
+  If you say yes here you get support for the TDA8026 Smart card PHY
+ with I2C interface.
+
 source drivers/misc/c2port/Kconfig
 source drivers/misc/eeprom/Kconfig
 source drivers/misc/cb710/Kconfig
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index f45473e..24374dd 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -53,3 +53,4 @@ obj-$(CONFIG_VMWARE_VMCI) += vmw_vmci/
 obj-$(CONFIG_LATTICE_ECP3_CONFIG)  += lattice-ecp3-config.o
 obj-$(CONFIG_SRAM) += sram.o
 obj-y  += mic/
+obj-$(CONFIG_NXP_TDA8026_PHY)  += tda8026.o
diff --git a/drivers/misc/tda8026.c b/drivers/misc/tda8026.c
new file mode 100644
index 000..6a77686
--- /dev/null
+++ b/drivers/misc/tda8026.c
@@ -0,0 +1,1255 @@
+/*
+ * tda8026.c - TDA8026 PHY driver for NXP Smart card PHY
+ *
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * 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 version 2.
+ *
+ * This program is distributed as is WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include linux/module.h
+#include linux/moduleparam.h
+#include linux/interrupt.h
+#include linux/init.h
+#include linux/slab.h
+#include linux/gpio.h
+#include linux/i2c.h
+#include linux/mfd/core.h
+#include linux/notifier.h
+#include linux/sc_phy.h
+#include linux/of_gpio.h
+#include linux/of_device.h
+#include linux/delay.h
+
+#define TDA8026_MAX_SLOTS  (5)
+#define TDA8026_NUM_SAM_SLOTS  (4)
+#define TDA8026_USERCARD_SLOT  (1)
+
+#define TDA8026_CSB_ADDR   (0x24)
+#define TDA8026_REG0_ADDR  (0x20)
+#define TDA8026_REG1_ADDR  (0x21)
+#define TDA8026_SLEWRATE_ADDR  (0x20)
+#define TDA8026_PRODVER_ADDR   (0x20)
+#define TDA8026_INTSTAT_ADDR   (0x21)
+
+#define TDA8026_PHY_PRODUCT_VERSION(0xC2)
+
+/* CSB register values */
+#define TDA8026_CSB_PV_INTSTAT_VAL (0x0)
+#define TDA8026_CSB_SLEWRATE_VAL   (0x6)
+
+/* Slot REG0 read mode bit fields */
+#define TDA8026_REG0_ACTIVE_MASK   (0x80)
+#define TDA8026_REG0_EARLY_MASK(0x40)
+#define TDA8026_REG0_MUTE_MASK (0x20)
+#define TDA8026_REG0_PROT_MASK (0x10)
+#define TDA8026_REG0_SUPL_MASK (0x08)
+#define TDA8026_REG0_CLKSW_MASK(0x04)
+#define TDA8026_REG0_PREL_MASK (0x02)
+#define TDA8026_REG0_PRES_MASK (0x01)
+
+/* Slot REG0 write mode bit

Re: [RFC PATCH v1 0/2] clock and HWMOD changes for USIM module

2014-01-09 Thread Satish Patel


On 1/6/2014 5:42 PM, Satish Patel wrote:
 Patch set includes clock and HWMOD entries for AM43x's USIM modoule.
 
 Note: I am in process of mainlining usim driver.
 
 Satish Patel (2):
   ARM: dts: AM43xx-clocks: Entries added for ti-usim
   ARM: OMAP: AM43xx: HWMOD changes added for ti-usim
 

Tony,

Can you pull in these patches if there are no comments?

Thanks,
Satish
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH v1 0/5] Smart Card(SC) interface, TI USIM NxP SC phy driver

2014-01-06 Thread Satish Patel
 smart card voltage to be set
from application. As per EMV standard - smartcard should support
1.8/3/5V volts. It defines class of smart card.

Smart card can be enumerated with either of voltage level (if it is
EMV) but further operation to smart card should be done with voltage
level information which comes as a part of answer to reset. - ATR
byes will be parsed by user level stack, as it contains vendor ( who
supply the smart card and end application which will work with that
card like VISA) specific information 

Ref# - section# voltage selection
http://anonscm.debian.org/viewvc/pcsclite/trunk/Drivers/ccid/README?view=markup

EMV - book1 section# supply voltage
http://www.emvco.com/specifications.aspx?id=223


Que: Why pin configuration settings are exposed ?
Ans: Mostly all memory based (synchronous) cards runs on propriety
algorithm running on user space. Algorithm toggles the level on pins
like -i/o,clock,c4,rst to get require information from the smart
card. These smart card are customized by vendor/product owner.

Que: Why interface like activation/deactivation and warm-reset are
exposed ? Can't it be done as a part of phy initialization ?
Ans: Here activation/deactivation is different than power on/off for
smart card phy. This is an activation and deactivation of smart card
not the phy. Normally in case of smart card - user application/stack
will decide when to carry out this sequence once card is inserted to
the slot. 
e.g. Certain stack will carry out warm reset if activation fails and
some will decide to do de-activation. 
http://pcsclite.alioth.debian.org/api/group__IFDHandler.html

Que: Why not generic phy framework ?
Ans: We will be more than happy to adapt generic phy if it
includes/add support for smart card requirement.

Currently,
(1) That does not support the requirement of memory card and EMV
card, where application (who are supplying smartcards) need 
control to set voltage, and timing parameters.
(2) Does not support warm reset and does not expose pin configuration
to application.
(3) Does not support notification of events from phy.


References
--
[1] NxP Phy's datasheet
www.nxp.com/documents/data_sheet/TDA8026.pdf
http://www.nxp.com/documents/application_note/AN10724.pdf

[2] TI smart card controller
coming soon

[3] EVM specification
http://www.emvco.com

[4] Smart card framework and applications
https://code.google.com/p/cardpeek
http://www.linuxnet.com/index.html

Satish Patel (5):
  sc_phy:SmartCard(SC) PHY interface to SC controller
  misc: tda8026: Add NXP TDA8026 PHY driver
  char: ti-usim: Add driver for USIM module on AM43xx
  ARM: dts: AM43xx: DT entries added for ti-usim
  ARM: dts: AM43xx-epos-evm: DT entries  for ti-usim

 Documentation/devicetree/bindings/misc/tda8026.txt |   14 +
 .../devicetree/bindings/ti-usim/ti-usim.txt|   31 +
 Documentation/sc_phy.txt   |  171 ++
 arch/arm/boot/dts/am4372.dtsi  |   11 +
 arch/arm/boot/dts/am43x-epos-evm.dts   |   30 +
 drivers/char/Kconfig   |7 +
 drivers/char/Makefile  |1 +
 drivers/char/ti-usim-hw.h  |  863 +
 drivers/char/ti-usim.c | 1851 
 drivers/misc/Kconfig   |7 +
 drivers/misc/Makefile  |1 +
 drivers/misc/tda8026.c | 1271 ++
 include/linux/sc_phy.h |  132 ++
 include/linux/ti-usim.h|   97 +
 14 files changed, 4487 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/misc/tda8026.txt
 create mode 100644 Documentation/devicetree/bindings/ti-usim/ti-usim.txt
 create mode 100644 Documentation/sc_phy.txt
 create mode 100644 drivers/char/ti-usim-hw.h
 create mode 100644 drivers/char/ti-usim.c
 create mode 100644 drivers/misc/tda8026.c
 create mode 100644 include/linux/sc_phy.h
 create mode 100644 include/linux/ti-usim.h

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


[RFC PATCH v1 4/5] ARM: dts: AM43xx: DT entries added for ti-usim

2014-01-06 Thread Satish Patel
SoC specific DT entries added for TI's USIM - smart card controller of AM43xx
platfrom.

Signed-off-by: Satish Patel satish.pa...@ti.com
---
 arch/arm/boot/dts/am4372.dtsi |   11 +++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/am4372.dtsi b/arch/arm/boot/dts/am4372.dtsi
index fc220a4..cc47aff 100644
--- a/arch/arm/boot/dts/am4372.dtsi
+++ b/arch/arm/boot/dts/am4372.dtsi
@@ -1071,6 +1071,17 @@
clocks = mcasp1_fck;
clock-names = fck;
};
+
+   usim0: usim@48034000 {
+   compatible = ti,usim;
+   reg = 0x48034000 0x1000;
+   interrupts = GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH;
+   ti,hwmods = usim0;
+   clocks = usim0_opt_fck, usim0_opt_fck32;
+   clock-names = opt_fck, opt_fck32;
+   status = disabled;
+   };
+
};
 
clocks {
-- 
1.7.1

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


[RFC PATCH v1 5/5] ARM: dts: AM43xx-epos-evm: DT entries for ti-usim

2014-01-06 Thread Satish Patel
Board specific DT entries for TI's USIM - smart card controller of AM43xx
platfrom.These entries are used by USIM driver for various configurations.

Shutdown line of NXP phy is maped to GPIO5. So enabling same to have support
for NXP phy.

Signed-off-by: Satish Patel satish.pa...@ti.com
---
 arch/arm/boot/dts/am43x-epos-evm.dts |   30 ++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/am43x-epos-evm.dts 
b/arch/arm/boot/dts/am43x-epos-evm.dts
index f20559b..4ca3460 100644
--- a/arch/arm/boot/dts/am43x-epos-evm.dts
+++ b/arch/arm/boot/dts/am43x-epos-evm.dts
@@ -202,6 +202,17 @@
;
};
 
+   usim0_default: usim0_default {
+   pinctrl-single,pins = 
+   /* USIM 0 */
+   0x1B4 (SLEWCTRL_FAST | PULL_DISABLE | MUX_MODE8)
/* CLK0  */
+   0x1B0 (SLEWCTRL_FAST | PULL_DISABLE | MUX_MODE8)
/* CLK1  */
+   0x1B8 (SLEWCTRL_FAST | INPUT_EN | PULL_DISABLE | 
MUX_MODE8) /* DATA0 */
+   0x1BC (SLEWCTRL_FAST | INPUT_EN | PULL_DISABLE | 
MUX_MODE8) /* DATA1 */
+   0x1C8 (SLEWCTRL_FAST | INPUT_EN | PULL_UP | MUX_MODE8)  
/* IRQn  */
+   ;
+   };
+
spi0_pins: pinmux_spi0_pins {
pinctrl-single,pins = 
0x150 (PIN_INPUT | MUX_MODE0)   /* 
spi0_clk.spi0_clk */
@@ -328,6 +339,11 @@
status = okay;
 };
 
+gpio5 {
+   status = okay;
+};
+
+
 dpi {
pinctrl-names = default;
pinctrl-0 = dss_pinctrl;
@@ -478,6 +494,14 @@
};
 };
 
+usim0 {
+   pinctrl-names = default;
+   pinctrl-0 = usim0_default;
+   phy = tda8026;
+   phy-slots = 1;
+   status = okay;
+};
+
 i2c2 {
pinctrl-names = default;
pinctrl-0 = i2c2_pins;
@@ -490,6 +514,12 @@
video-source = dpi;
data-lines = 24;
};
+   tda8026: tda8026@48 {
+   compatible = nxp,tda8026;
+   reg = 0x48;
+   shutdown-gpio = gpio5 19 GPIO_ACTIVE_HIGH;   /* Bank5, pin19 
*/
+   interrupts = GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH;
+   };
 };
 
 spi0 {
-- 
1.7.1

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


[RFC PATCH v1 2/5] misc: tda8026: Add NXP TDA8026 PHY driver

2014-01-06 Thread Satish Patel
TDA8026 is a SmartCard PHY from NXP.

The PHY interfaces with the main processor over the
I2C interface and acts as a slave device.

The driver also exposes the phy interface
(defined@include/linux/sc_phy.h) for SmartCard controller.
Controller uses this interface to communicate with smart card
inserted to the phy's slot.

Note: gpio irq is not validated as I do not have device with that.
I have validated interrupt with dedicated interrupt line on my device.

Signed-off-by: Maulik Mankad mau...@ti.com
Signed-off-by: Satish Patel satish.pa...@ti.com
---
 Documentation/devicetree/bindings/misc/tda8026.txt |   14 +
 drivers/misc/Kconfig   |7 +
 drivers/misc/Makefile  |1 +
 drivers/misc/tda8026.c | 1271 
 4 files changed, 1293 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/misc/tda8026.txt
 create mode 100644 drivers/misc/tda8026.c

diff --git a/Documentation/devicetree/bindings/misc/tda8026.txt 
b/Documentation/devicetree/bindings/misc/tda8026.txt
new file mode 100644
index 000..d3083bf
--- /dev/null
+++ b/Documentation/devicetree/bindings/misc/tda8026.txt
@@ -0,0 +1,14 @@
+TDA8026 smart card slot interface
+
+Required properties:
+- compatible: nxp,tda8026
+- shutdown-gpio = GPIO pin mapping for SDWNN pin
+- reg = i2c interface address
+
+
+Example:
+tda8026: tda8026@48 {
+compatible = nxp,tda8026;
+reg = 0x48;
+shutdown-gpio = gpio5 19 GPIO_ACTIVE_HIGH;/* Bank5, pin19 */
+};
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index f1da896..6bbc1c7 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -536,6 +536,13 @@ config CROSSBAR
  muxing the irq/dma requests from external peripherals to the 
corresponding
  controller's inputs.
 
+config NXP_TDA8026_PHY
+tristate NXP PHY Driver for Smart Card PHY
+depends on I2C=y
+help
+  If you say yes here you get support for the TDA8026 Smart card PHY
+ with I2C interface.
+
 source drivers/misc/c2port/Kconfig
 source drivers/misc/eeprom/Kconfig
 source drivers/misc/cb710/Kconfig
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 37ce1b8..853b225 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -54,3 +54,4 @@ obj-$(CONFIG_VMWARE_VMCI) += vmw_vmci/
 obj-$(CONFIG_LATTICE_ECP3_CONFIG)  += lattice-ecp3-config.o
 obj-$(CONFIG_SRAM) += sram.o
 obj-$(CONFIG_CROSSBAR) += crossbar.o
+obj-$(CONFIG_NXP_TDA8026_PHY)  += tda8026.o
diff --git a/drivers/misc/tda8026.c b/drivers/misc/tda8026.c
new file mode 100644
index 000..b24e948
--- /dev/null
+++ b/drivers/misc/tda8026.c
@@ -0,0 +1,1271 @@
+/*
+ * tda8026.c - TDA8026 PHY driver for NXP Smart card PHY
+ *
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * 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 version 2.
+ *
+ * This program is distributed as is WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include linux/module.h
+#include linux/moduleparam.h
+#include linux/interrupt.h
+#include linux/init.h
+#include linux/slab.h
+#include linux/gpio.h
+#include linux/i2c.h
+#include linux/mfd/core.h
+#include linux/notifier.h
+#include linux/sc_phy.h
+#include linux/of_gpio.h
+#include linux/of_device.h
+#include linux/delay.h
+
+#define TDA8026_MAX_SLOTS  (5)
+#define TDA8026_NUM_SAM_SLOTS  (4)
+#define TDA8026_USERCARD_SLOT  (1)
+
+#define TDA8026_CSB_ADDR   (0x24)
+#define TDA8026_REG0_ADDR  (0x20)
+#define TDA8026_REG1_ADDR  (0x21)
+#define TDA8026_SLEWRATE_ADDR  (0x20)
+#define TDA8026_PRODVER_ADDR   (0x20)
+#define TDA8026_INTSTAT_ADDR   (0x21)
+
+#define TDA8026_PHY_PRODUCT_VERSION(0xC2)
+
+/* CSB register values */
+#define TDA8026_CSB_PV_INTSTAT_VAL (0x0)
+#define TDA8026_CSB_SLEWRATE_VAL   (0x6)
+
+/* Slot REG0 read mode bit fields */
+#define TDA8026_REG0_ACTIVE_MASK   (0x80)
+#define TDA8026_REG0_EARLY_MASK(0x40)
+#define TDA8026_REG0_MUTE_MASK (0x20)
+#define TDA8026_REG0_PROT_MASK (0x10)
+#define TDA8026_REG0_SUPL_MASK (0x08)
+#define TDA8026_REG0_CLKSW_MASK(0x04)
+#define TDA8026_REG0_PREL_MASK (0x02)
+#define TDA8026_REG0_PRES_MASK (0x01)
+
+/* Slot REG0 write mode bit fields */
+#define TDA8026_REG0_VCC1V8_MASK   (0x80)
+#define TDA8026_REG0_IOEN_MASK (0x40)
+
+#define TDA8026_REG0_REG10_MASK(0x30)
+#define TDA8026_REG0_REG10_SHIFT   (4

[RFC PATCH v1 1/5] sc_phy:SmartCard(SC) PHY interface to SC controller

2014-01-06 Thread Satish Patel
SmartCard controller uses this interface to communicate with
SmartCard via PHY

Some SmartCard PHY has multiple slots for cards.
This inerface also enables controller to communicate
with one or more SmartCard connected over phy.

interface structure includes following APIs
- set/get config
- activate/deactivate smart card
- warm reset
- register_notify (for card insert/remove/overheat)
- unregister_notify

Signed-off-by: Satish Patel satish.pa...@ti.com
---
 Documentation/sc_phy.txt |  171 ++
 include/linux/sc_phy.h   |  132 +++
 2 files changed, 303 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/sc_phy.txt
 create mode 100644 include/linux/sc_phy.h

diff --git a/Documentation/sc_phy.txt b/Documentation/sc_phy.txt
new file mode 100644
index 000..d610e26
--- /dev/null
+++ b/Documentation/sc_phy.txt
@@ -0,0 +1,171 @@
+   SmartCard PHY Interface
+   Satish Patel satish.pa...@ti.com
+
+This document explains the SmartCard interface between SmartCard
+controller and SmartCard phy. Document also describes how-to-use.
+
+1. Why SmartCard PHY Interface?
+
+The use of smartcard is increasing in embedded industry. As smartcard
+not only prevent duplication but also, brings key based authentication
+flow into picture.
+
+SmartCard standards like EMV(EuroPay-Mastercard-Visa) are becoming
+mandatory for payment terminals.
+
+Till date, most of the SmartCard readers are based on USB serial
+interface. Which drives its logic within firmware lies on device.
+Few are based on FPGA solutions. But now SoCs are coming up with
+inbuilt smartcard controller. e.g. TI-AM43x
+
+Role of SmartCard controller and SmartCard phy:
+
+Smartcard Phy:
+Forms electrical interface between controller and SmartCard. Phy
+enables access to more than one smartcard and in addition it provides
+fast deactivation logic when card gets removed from the slot. It can
+also generate the signals like card insert/remove/overheat etc.
+
+Smartcard Controller:
+In built mechanism to meet EMV L1 specification (e.g. T=0, T=1
+protocol timings, ATR timeout etc..) for SmartCard transaction. In
+addition to this, it has FIFO to store tx/rx bytes, internal state
+machine for ATR, Tx/Rx, Synchronous/Asynchronous mode, timing
+counters etc..
+
+Controller can also have direct interface through which SmartCard
+can be connected without phy.
+
+Below is the brief of SmartCard block diagram from user to h/w
+layer.
+
+
+---
+|PC/SC App|
+---
+--- ---
+|PC/SC F/W| | Visa APP|
+--- ---
+--- 
+|IFD Hand.| | EMV L1/L2|| Test App |
+--- 
+User Space
+
+
+-
+|   SmartCard Controller Driver|
+-
+ | |
+ | |
+-  |
+| Phy Driver | |
+-  |
+ | |
+Kernel Space | |
+
+ | |
+   -  
+   | PHY   |  |Controller IP |
+   -  
+|   |
+
+|   |
+   ___
+   |||
+ VISA card   Master Card  Custom Card
+
+
+At present in Linux there is no public interface exist which acts as
+bridge between controller and phy. Mostly vendors uses proprietary
+solution in such cases.
+
+2. Introduction to SmartCard PHY interface
+
+SmartCard PHY interface that exposes phy's capabilities to the smart
+card controller. SmartCard controller uses this interface to
+communicate with SmartCard via phy.
+
+Such capabilities are:
+1) Some SmartCard phy (e.g. TDA8026-NxP) has multiple slots for smart
+cards. This interface enables controller to communicate with specific
+SmartCard inserted to the specific phy's slot.
+
+2) Warm reset to SmartCard inserted to phy slot.
+
+3) Bit banging of SmartCard pins to support vedor specific memory
+cards. Mostly when it comes to sychorous SmartCard
+
+4) Notification of card insert/remove/overheat etc.
+
+
+3. How to use
+
+SmartCard PHY:
+The SmartCard PHY driver, who wants to be interfaced with SmartCard
+controller require to follow below step
+
+- include sc_phy.h
+
+- use sc_phy structure as driver(client

[RFC PATCH v1 1/2] ARM: dts: AM43xx-clocks: Entries added for ti-usim

2014-01-06 Thread Satish Patel
Clock  entries support for TI's USIM - Smart card controller of AM43xx platform
USIM controller has multiple sources for debounce and functional clock.Entry
for each source has been added.

Signed-off-by: Satish Patel satish.pa...@ti.com
---
 arch/arm/boot/dts/am43xx-clocks.dtsi |   34 ++
 drivers/clk/ti/clk-43xx.c|4 
 2 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/am43xx-clocks.dtsi 
b/arch/arm/boot/dts/am43xx-clocks.dtsi
index c127e7b..7ccfa75 100644
--- a/arch/arm/boot/dts/am43xx-clocks.dtsi
+++ b/arch/arm/boot/dts/am43xx-clocks.dtsi
@@ -420,6 +420,40 @@ wdt1_fck: wdt1_fck@44df422c {
bit-mask = 0x1;
 };
 
+usim0_fck: usim0_fck@44df4254 {
+   #clock-cells = 0;
+   compatible = mux-clock;
+   clocks = sys_clkin_ck, dpll_core_m4_ck;
+   reg = 0x44df4254 0x4;
+   bit-mask = 0x1;
+};
+
+usim_dbck: usim_dbck@44df425c {
+   #clock-cells = 0;
+   compatible = mux-clock;
+   clocks = clk_rc32k_ck, clk_32k_mosc_ck, clkdiv32k_ick;
+   reg = 0x44df425c 0x4;
+   bit-mask = 0x3;
+};
+
+usim0_opt_fck: usim0_opt_fck@44df8da8 {
+   #clock-cells = 0;
+   compatible = gate-clock;
+   clocks = usim0_fck;
+   reg = 0x44df8da8 0x4;
+   bit-shift = 8;
+   bit-mask = 0x1;
+};
+
+usim0_opt_fck32: usim0_opt_fck32@44df8da8 {
+   #clock-cells = 0;
+   compatible = gate-clock;
+   clocks = usim_dbck;
+   bit-shift = 9;
+   bit-mask = 0x1;
+   reg = 0x44df8da8 0x4;
+};
+
 l3_gclk: l3_gclk {
#clock-cells = 0;
compatible = fixed-factor-clock;
diff --git a/drivers/clk/ti/clk-43xx.c b/drivers/clk/ti/clk-43xx.c
index ff3ad1b..8ed05f2 100644
--- a/drivers/clk/ti/clk-43xx.c
+++ b/drivers/clk/ti/clk-43xx.c
@@ -66,6 +66,10 @@ static struct omap_dt_clk am43xx_clks[] = {
DT_CLK(NULL, timer6_fck, timer6_fck),
DT_CLK(NULL, timer7_fck, timer7_fck),
DT_CLK(NULL, wdt1_fck, wdt1_fck),
+   DT_CLK(NULL, usim0_fck, usim0_fck),
+   DT_CLK(NULL, usim_dbck, usim_dbck),
+   DT_CLK(NULL, usim0_opt_fck, usim0_opt_fck),
+   DT_CLK(NULL, usim0_opt_fck32, usim0_opt_fck32),
DT_CLK(NULL, l3_gclk, l3_gclk),
DT_CLK(NULL, dpll_core_m4_div2_ck, dpll_core_m4_div2_ck),
DT_CLK(NULL, l4hs_gclk, l4hs_gclk),
-- 
1.7.1

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


[RFC PATCH v1 0/2] clock and HWMOD changes for USIM module

2014-01-06 Thread Satish Patel
Patch set includes clock and HWMOD entries for AM43x's USIM modoule.

Note: I am in process of mainlining usim driver.

Satish Patel (2):
  ARM: dts: AM43xx-clocks: Entries added for ti-usim
  ARM: OMAP: AM43xx: HWMOD changes added for ti-usim

 arch/arm/boot/dts/am43xx-clocks.dtsi   |   34 
 arch/arm/mach-omap2/omap_hwmod_33xx_data.c |   39 
 arch/arm/mach-omap2/prcm43xx.h |1 +
 drivers/clk/ti/clk-43xx.c  |4 +++
 4 files changed, 78 insertions(+), 0 deletions(-)

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


[RFC PATCH v1 2/2] ARM: OMAP: AM43xx: HWMOD changes added for ti-usim

2014-01-06 Thread Satish Patel
HWMOD entries support for TI's USIM - Smart card controller of AM43xx platform

Signed-off-by: Satish Patel satish.pa...@ti.com
---
 arch/arm/mach-omap2/omap_hwmod_33xx_data.c |   39 
 arch/arm/mach-omap2/prcm43xx.h |1 +
 2 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod_33xx_data.c 
b/arch/arm/mach-omap2/omap_hwmod_33xx_data.c
index 5a629f2..f9bfdec 100644
--- a/arch/arm/mach-omap2/omap_hwmod_33xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_33xx_data.c
@@ -1689,6 +1689,35 @@ static struct omap_hwmod am33xx_usbss_hwmod = {
},
 };
 
+/* usim0 */
+static struct omap_hwmod_class_sysconfig am43xx_usim0_sysc = {
+   .rev_offs   = 0x0,
+   .sysc_offs  = 0x10,
+   .sysc_flags = (SYSC_HAS_SIDLEMODE),
+   .idlemodes  = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
+   SIDLE_SMART_WKUP),
+   .sysc_fields= omap_hwmod_sysc_type1,
+};
+
+static struct omap_hwmod_class am43xx_usim0_hwmod_class = {
+   .name   = usim,
+   .sysc   = am43xx_usim0_sysc,
+};
+
+static struct omap_hwmod am43xx_usim0_hwmod = {
+   .name   = usim0,
+   .class  = am43xx_usim0_hwmod_class,
+   .clkdm_name = l4ls_clkdm,
+   .main_clk   = l4ls_gclk,
+   .prcm   = {
+   .omap4  = {
+   .clkctrl_offs   = 
AM43XX_CM_PER_USIM0_CLKCTRL_OFFSET,
+   .modulemode = MODULEMODE_SWCTRL,
+   },
+   },
+};
+
+
 static struct omap_hwmod_class_sysconfig am43xx_synctimer_sysc = {
.rev_offs   = 0x0,
.sysc_offs  = 0x4,
@@ -2901,6 +2930,14 @@ static struct omap_hwmod_ocp_if am43xx_l4_ls__mcspi4 = {
.user   = OCP_USER_MPU,
 };
 
+static struct omap_hwmod_ocp_if am43xx_l4_ls__usim0 = {
+   .master = am33xx_l4_ls_hwmod,
+   .slave  = am43xx_usim0_hwmod,
+   .clk= l4ls_gclk,
+   .user   = OCP_USER_MPU,
+};
+
+
 static struct omap_hwmod_ocp_if am43xx_l4_ls__gpio4 = {
.master = am33xx_l4_ls_hwmod,
.slave  = am43xx_gpio4_hwmod,
@@ -3083,6 +3120,7 @@ static void am43xx_hwmod_clkctrl(void)
CLKCTRL(am33xx_sha0_hwmod , AM43XX_CM_PER_SHA0_CLKCTRL_OFFSET);
CLKCTRL(am33xx_aes0_hwmod , AM43XX_CM_PER_AES0_CLKCTRL_OFFSET);
CLKCTRL(am33xx_rng_hwmod , AM43XX_CM_PER_RNG_CLKCTRL_OFFSET);
+   CLKCTRL(am43xx_usim0_hwmod , AM43XX_CM_PER_USIM0_CLKCTRL_OFFSET);
 }
 
 static void am33xx_hwmod_clkctrl(void)
@@ -3256,6 +3294,7 @@ static struct omap_hwmod_ocp_if *am43xx_hwmod_ocp_ifs[] 
__initdata = {
am43xx_l4_ls__dss,
am43xx_l4_ls__dss_dispc,
am43xx_l4_ls__dss_rfbi,
+   am43xx_l4_ls__usim0,
NULL,
 };
 
diff --git a/arch/arm/mach-omap2/prcm43xx.h b/arch/arm/mach-omap2/prcm43xx.h
index 93a1953..d8aa310 100644
--- a/arch/arm/mach-omap2/prcm43xx.h
+++ b/arch/arm/mach-omap2/prcm43xx.h
@@ -146,5 +146,6 @@
 #define AM43XX_CM_PER_GPIO5_CLKCTRL_OFFSET 0x0498
 #define AM43XX_CM_PER_DSS_CLKCTRL_OFFSET   0x0a20
 #define AM43XX_CM_PER_MAGADC_CLKCTRL_OFFSET0x0230
+#define AM43XX_CM_PER_USIM0_CLKCTRL_OFFSET  0x05A8
 
 #endif
-- 
1.7.1

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


Re: [RFC PATCH v1 2/5] misc: tda8026: Add NXP TDA8026 PHY driver

2014-01-06 Thread Satish Patel


On 1/6/2014 9:00 PM, Mark Rutland wrote:
 On Mon, Jan 06, 2014 at 12:07:39PM +, Satish Patel wrote:
 TDA8026 is a SmartCard PHY from NXP.

 The PHY interfaces with the main processor over the
 I2C interface and acts as a slave device.

 The driver also exposes the phy interface
 (defined@include/linux/sc_phy.h) for SmartCard controller.
 Controller uses this interface to communicate with smart card
 inserted to the phy's slot.

 Note: gpio irq is not validated as I do not have device with that.
 I have validated interrupt with dedicated interrupt line on my device.

 Signed-off-by: Maulik Mankad mau...@ti.com
 Signed-off-by: Satish Patel satish.pa...@ti.com
 ---
  Documentation/devicetree/bindings/misc/tda8026.txt |   14 +
  drivers/misc/Kconfig   |7 +
  drivers/misc/Makefile  |1 +
  drivers/misc/tda8026.c | 1271 
 
  4 files changed, 1293 insertions(+), 0 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/misc/tda8026.txt
  create mode 100644 drivers/misc/tda8026.c

 diff --git a/Documentation/devicetree/bindings/misc/tda8026.txt 
 b/Documentation/devicetree/bindings/misc/tda8026.txt
 new file mode 100644
 index 000..d3083bf
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/misc/tda8026.txt
 @@ -0,0 +1,14 @@
 +TDA8026 smart card slot interface
 +
 +Required properties:
 +- compatible: nxp,tda8026
 
 Please quote strings:
 
 - compatible: should contain nxp,tda8026
ok
 
 +- shutdown-gpio = GPIO pin mapping for SDWNN pin
 +- reg = i2c interface address
 
 It's probably worth mentioning at the start that this is an i2c device.
 
 [...]
ok
 
 +static int tda8026_parse_dt(struct device *dev, struct tda8026 *pdata)
 +{
 +   struct device_node *np = dev-of_node;
 +   const struct of_device_id *match;
 +   int ret = 0;
 +
 +   match = of_match_device(of_match_ptr(tda8026_id_table), dev);
 +   if (!match)
 +   return -EINVAL;
 
 Why do this? The of_device_id table contains one entry with no
 additional data. If you just want to see if this was probed via DT,
 dev-of_node not being NULL would tell you that.
 
agree..
 Is this going to be used without DT anywhere?
 
 [...]
 
 +   if (pdata-irq == 0) {
 +   /* look for the field irq-gpio in DT */
 +   irq_gpio = of_get_named_gpio(np, irq-gpio, 0);
 +   if (!gpio_is_valid(irq_gpio)) {
 +   dev_err(dev, Failed to get irq gpio,\n);
 +   return -EIO;
 +   }
 
 This is horrible. If the gpio controller can act as an irq controller

No it's not true. Let me clarify the signal flow,

Pins = GPIO = GPIO BANK = Interrupt controller = CPU/MPU

 then it should be annotated as such, with #interrupt-cells, and you
 should just describe the interrupt. The smart card controller cares
 about having an interrupt line, not a GPIO.
 

Let me quote MMC card-detect example here,
File: drivers/mmc/host/omap_hsmmc.c

Card detection is happening through GPIO (same as what this patch is
doing). Please refer to the probe sequence, you will find exactly same
thing there too.


AM437x device has a special feature for the USIM Phy, where the PHY
interrupt automatically gets hooked up to interrupt-controller and
the driver gets interrupt number from DT using #interrupt-cells, exactly
what you had mentioned.
But if same PHY gets interfaced to other SoC's over GPIO, then in order
to handle that scenario you __must__ go through gpio_to_irq().

Let me add another important point here,
You can not determine irq number for the given GPIO, as it gets
allocated dynamically based on GPIO banks supported on the device and on
the board.

 Additionally, this was not described in the binding.
 
 Thanks,
 Mark.
 
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html