Skip to content

Generic PHY Framework

Felipe Balbi linux-arm-kernel linux-devicetree linux-omap lkml 5 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v9 Latest posting 5/50 of 8 patches 0 repliesNew
  2. v9 posting 4/50 of 8 patches 0 repliesSuperseded
  3. v9 posting 3/50 of 8 patches 0 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v9 posting 2/50 of 8 patches0 repliesSuperseded
v9 posting 1/50 of 8 patches0 repliesSuperseded

Patches in v9 posting 5/5 No applies recorded yet

None of the 8 patches the cover letter announces are in this archive.

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v9 yet.

Read the v9 thread

Cover letter [PATCH v9 0/8] Generic PHY Framework

Hi,

Quoted 21 lines · Satish
Quoted 5 lines
Quoted 5 lines

Operation:

Once the card gets inserted into the slot, user application can initiate activate sequence anytime, it is not mandatory that activation has to be called Immediately. It all depends whether

Quoted 7 lines

other

Quoted 2 lines

connections ( network, printer) are proper. User application can do some checks and then dynamically activate the card

The card or the phy ? Who actually activates ? Is the activation handling part of the PHY or part of the smartcard controller ?

It?s a activation of smart card which is inserted into the phy slot. Smart card activation will by done phy but initiated by user application Handling of activation should be done at both the side - controller as well As phy. Phy will raise certain signals and check timeout while activation , while controller will store data coming from smart card to FIFO. Its Controller which will give command to phy to initiate activation sequence when it is ready.

Quoted 2 lines

Which means, both controller and phy has role to play while activation. Also it is applicable while deactivation.

right, so when the smartcard device is opened, you want to powerup the PHY, powerup the smartcard controller and get things going, which means that all your activation logic can, and should, be hidden by phy_power_on() and phy_power_off()

Perhaps you also want to delay phy_init() and phy_shutdown() to that very time, which would mean that we wouldn't even need phy_power_{on,off}() calls whatsoever.

Quoted 13 lines
Quoted 5 lines
Quoted 1 line

There are 2 sequence of activation - normal activation and warm

reset.

Quoted 2 lines

If first fails then warm reset should be executed, if card does not response to both then deactivation will be carried out

Quoted 7 lines

ret = phy_resume(phy);
if (ret == -EINVAL) { /* perhaps there's a better error code */

	ret = phy_reset(phy);
	if (ret)
		phy_suspend(phy);
}
Quoted 4 lines

Its not like this. There are the cases, when during normal activation card respond With some characters, but they might not be valid or error prone - This check will be done by user application as only application knows how to decode characters as per protocol.

sure, and if the characters are invalid, the application needs to tell the kernel, perhaps it would be enough to send and IOCTL or, even easier, close the device and reopen it.

Quoted 2 lines

It there is any error in characters/timeout paratmeters, user application will ask to initiate Warm reset.

and for that we can use an IOCTL which is implemented by smart card layer. I mean, I'm assuming the smartcard would be seen as a char dev by userland so it would be something like this:

ret = read(fd, buf, SIZE);
if (ret < 0)

	boom();

ret = process_buffer(buf, ret);
if (ret == -EINVAL) { /* we have received invalid characters */

	ret = ioctl(fd, IOCTL_SMARTCARD_WARM_RESET);
	if (ret < 0)
		handle_error();
}

in kernel space we would have an ioctl handler like so:

static int smart_card_ioctl(struct file *fd, unsigned code, usigned long v)

{
	struct smart_card *sc = fd->private_data;
	unsigned long flags;
	int ret;

	spin_lock_irqsave(&sc->lock, flags);
	switch (v)
	case SMART_CARD_WARM_RESET:
		ret = phy_shutdown(sc->phy);
		if (ret < 0)
			boom();

		ret = smart_card_reset(sc);
		if (ret < 0)
			boom();

		ret = phy_init(sc->phy);
		if (ret < 0)
			boom();
		break;
	[ ... ]
	}

	spin_unlock_irqrestore(&sc->lock, flags);

	return ret;
}

see, we don't need to add a bunch of stuff in the PHY framework, because you shouldn't expose the PHY directly to userland. You *must* have an abstraction to userland with an in-kernel usage of the PHY layer.

Quoted 7 lines
Quoted 7 lines
Quoted 1 line

- on activation card will respond with some initial characters

(ATR),

Quoted 5 lines

which will be verified by application, in case of error user application will de-activate the card not the phy module

- After activation, use application initiate normal tx/rx

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

- Once tx/rx is done, it will initiate deactivation of card not the phy module.

then that has nothing to do with the PHY framework, right ?

But all such sequence will be initiated by PHY by raising certain signals and only controller can give the push when to start.

sure, that's fair. But you don't need to expose every single detail of the PHY. You need to use abstractions to make accesses to the PHY easy to maintain. See the example above.

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

Smartcard_set_c4/c8/rst/io -> phy_set_pin

Whats should be exactly done here? Looks to me like it should be part of init. Does these pin settings need to be changed

dynamically?

Quoted 3 lines

These are all phy pins which will be physically come in contact with smart card When inserted. In case of synchronous card, these pins

Quoted 8 lines
Quoted 5 lines

will

Quoted 1 line

be toggled manually by s/w bit bang algorithm

is that a requirement or just something that everybody does ?

Its requirement for synchronous card. At present there is no open driver Which does this thing.

alright, so you need to tell the PHY in which mode it should work and the PHY driver needs to be smart enough to choose proper callbacks depending on the mode.

Quoted 5 lines
Quoted 2 lines

In any case, you can hide that under some gpio calls, or something similar.

Can't be done using GPIO as pin can be toggled only which i2c read/write to the phy.

so ? look at the numerous I2C GPIO expanders we have in the kernel ;-)

Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

Smartcard_get_version -> phy_get_version

Again why? Why would the smartcard need the version of the PHY?

Quoted 8 lines
Quoted 1 line

Can be omitted. This is for the test suite reference.

if it's for testsuite, it sounds like something that should be done through userland and, as such, should be implemented by a set of debugfs
files which expose the necessary information. That has nothing to do with the PHY framework.

Quoted 5 lines

Agree.. can be omitted.

I am ok to give internal webex presentation (TI team) to brief on phy and smart card controller interface.

let's try to cut down on internal agreements and let the community help defining a proper way to handle the PHY :-)

Still, if you want to point me and Kishon (privately) to some internal documentation, we can certainly read through it :-)

cheers

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130709/9c264c9a/attachment.sig>