Skip to contentSkip to conversation

Support for Silicon C2 Interface.

PATCH In review Rodolfo Giometti 3 participants 9 messages Oct 3, 2008 – Oct 7, 2008 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

C2 port implements a two wire serial communication protocol (bit banging) designed to enable in-system programming, debugging, and boundary-scan testing on low pin-count Silicon Labs devices.

Main references are at Silicon Laboratories site:

* AN127: FLASH Programming via the C2 Interface
http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/Small_Form_Factor/en/an127.pdf

* C2 Specification
http://www.silabs.com/public/documents/tpub_doc/spec/Microcontrollers/en/C2spec.pdf

Currently this code supports only flash programming through sysfs interface but extensions shoud be easy to add.

I know that this (proposal) patch may be incomplete but I'd like to know what you are thinking about it before continuing further. For example I'd like to know if should I put the C2 port core here or into proper subdirectory of linux/drivers/misc/ where clients can be placed also.

Thanks for your suggestions,

Rodolfo

--

 drivers/misc/Kconfig       |   13
 drivers/misc/Makefile      |    1
 drivers/misc/c2port_core.c |  996 +++++++++++++++++++++++++++++++++++++++++++++
 include/linux/c2port.h     |   65 ++
 4 files changed, 1075 insertions(+)
#1 lore raw

PATCH 1/1 Add c2 port support.

C2port implements a two wire serial communication protocol (bit banging) designed to enable in-system programming, debugging, and boundary-scan testing on low pin-count Silicon Labs devices.

Currently this code supports only flash programming through sysfs interface but extensions shoud be easy to add.

---
 drivers/misc/Kconfig       |   13 +
 drivers/misc/Makefile      |    1 +
 drivers/misc/c2port_core.c |  996 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/c2port.h     |   65 +++
 4 files changed, 1075 insertions(+), 0 deletions(-)
 create mode 100644 drivers/misc/c2port_core.c
 create mode 100644 include/linux/c2port.h
drivers/misc/Kconfig +13 -0
index a726f3b..c01cc35 100644
@@ -475,4 +475,17 @@ config SGI_GRU_DEBUG
 	This option enables addition debugging code for the SGI GRU driver. If
 	you are unsure, say N.
 
+config C2PORT
+	tristate "Silicon Labs C2 port support (EXPERIMENTAL)"
+	depends on EXPERIMENTAL
+	help
+	  This option enables support for Silicon Labs C2 port used to
+	  program Silicon uC chips (and other 8051 compatible).
+
+	  To compile this driver as a module, choose M here: the module will
+	  be called c2port_core. Note that you also need a client module
+	  usually called c2port-*.
+
+	  If you are not sure, say Y here.
+
 endif # MISC_DEVICES
drivers/misc/Makefile +1 -0
index c6c13f6..215bfd9 100644
@@ -30,3 +30,4 @@ obj-$(CONFIG_KGDB_TESTS)	+= kgdbts.o
 obj-$(CONFIG_SGI_XP)		+= sgi-xp/
 obj-$(CONFIG_SGI_GRU)		+= sgi-gru/
 obj-$(CONFIG_HP_ILO)		+= hpilo.o
+obj-$(CONFIG_C2PORT)		+= c2port_core.o
drivers/misc/c2port_core.c new file +996 -0

996 lines not on this page · raw message

include/linux/c2port.h new file +65 -0

65 lines not on this page · raw message

Signature · 1 line
1.5.4.3
#2 lore raw

Re: [PATCH 1/1] Add c2 port support.

Quoted 7 lines · Rodolfo Giometti

C2port implements a two wire serial communication protocol (bit banging) designed to enable in-system programming, debugging, and boundary-scan testing on low pin-count Silicon Labs devices.

Currently this code supports only flash programming through sysfs interface but extensions shoud be easy to add.

Quoted 6 lines
---
 drivers/misc/Kconfig       |   13 +
 drivers/misc/Makefile      |    1 +
 drivers/misc/c2port_core.c |  996 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/c2port.h     |   65 +++

Why does this file have to be in include/linux? I don't think this exports any structures to userspace, and no other code calls this driver, so it should all fit into the .c file just fine.

Also, please create the needed Documentation/ABI/ files for these new sysfs entries, describing how they are used, and what the format of them are.

Is there any way to detect automatically if this hardware is present in the system or not?

Otherwise, how will it be loaded by a distro automatically?

thanks,

greg k-h

#3 lore raw

Re: [PATCH 1/1] Add c2 port support.

Quoted 15 lines · Greg KH
Quoted 7 lines · Rodolfo Giometti

C2port implements a two wire serial communication protocol (bit banging) designed to enable in-system programming, debugging, and boundary-scan testing on low pin-count Silicon Labs devices.

Currently this code supports only flash programming through sysfs interface but extensions shoud be easy to add.

Quoted 6 lines
---
 drivers/misc/Kconfig       |   13 +
 drivers/misc/Makefile      |    1 +
 drivers/misc/c2port_core.c |  996 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/c2port.h     |   65 +++
Quoted 3 lines

Why does this file have to be in include/linux? I don't think this exports any structures to userspace, and no other code calls this driver, so it should all fit into the .c file just fine.

The inlcude file is needed because you have to define a clients for each c2 port implementations, see here for further info:

http://wiki.enneenne.com/index.php/Silicon_C2_Interface

The file c2port_core.c implements the core, a client implements the low level functions.

Quoted 3 lines

Also, please create the needed Documentation/ABI/ files for these new sysfs entries, describing how they are used, and what the format of them are.

Ok.

Quoted 2 lines

Is there any way to detect automatically if this hardware is present in the system or not?

I don't think so. The C2 port is usually implemented with two generic GPIOs.

Quoted 1 line

Otherwise, how will it be loaded by a distro automatically?

The C2 port client is usually defined into platform machine data file, for example I defined my client into linux/arch/arm/mach-pxa/wr1100.c (wr1100.c is not in a vanilla tree, refere to mainstone.c for similar code). In this manner the driver is autoloaded at boot time.

I posted the code in order to get some feedbacks and then repropose something suitable for inclusion. So I'd like to know if I should make a separate subdir into linux/drivers/misc/ to hold possible clients (i.e. linux/drivers/misc/c2port/).

Thanks for your suggestions,

Rodolfo

Signature · 4 lines
GNU/Linux Solutions                  e-mail: [email protected]
Linux Device Driver                          [email protected]
Embedded Systems                     phone:  +39 349 2432127
UNIX programming                     skype:  rodolfo.giometti
#4 lore raw

Re: [PATCH 1/1] Add c2 port support.

Quoted 16 lines · Rodolfo Giometti
Quoted 15 lines · Greg KH
Quoted 13 lines · Rodolfo Giometti

C2port implements a two wire serial communication protocol (bit banging) designed to enable in-system programming, debugging, and boundary-scan testing on low pin-count Silicon Labs devices.

Currently this code supports only flash programming through sysfs interface but extensions shoud be easy to add.

---
 drivers/misc/Kconfig       |   13 +
 drivers/misc/Makefile      |    1 +
 drivers/misc/c2port_core.c |  996 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/c2port.h     |   65 +++
Quoted 8 lines
Quoted 3 lines

Why does this file have to be in include/linux? I don't think this exports any structures to userspace, and no other code calls this driver, so it should all fit into the .c file just fine.

The inlcude file is needed because you have to define a clients for each c2 port implementations, see here for further info:

http://wiki.enneenne.com/index.php/Silicon_C2_Interface

You might want to flush out your Kconfig entry with more information from this site :)

Quoted 2 lines

The file c2port_core.c implements the core, a client implements the low level functions.

But you aren't submitting any clients here, right? Are you planning to?

Quoted 5 lines
Quoted 2 lines

Is there any way to detect automatically if this hardware is present in the system or not?

I don't think so. The C2 port is usually implemented with two generic GPIOs.

Then the default config option should be N, and you should make the Kconfig help text a bit clearer as to exactly which machines this device would be expected for, otherwise you might accidentally have distros add this device to their builds, which would not be a good thing.

Quoted 4 lines

I posted the code in order to get some feedbacks and then repropose something suitable for inclusion. So I'd like to know if I should make a separate subdir into linux/drivers/misc/ to hold possible clients (i.e. linux/drivers/misc/c2port/).

What's wrong with drivers/c2port/ ? Come on, think big :)

thanks,

greg k-h

#5 lore raw

Re: [PATCH 1/1] Add c2 port support.

Quoted 1 line · Greg KH

But you aren't submitting any clients here, right? Are you planning to?

Currently not, but I have 2 clients for my custom boards... maybe I can add one of them which uses an x86 IO port to do the job.

Quoted 4 lines

Then the default config option should be N, and you should make the Kconfig help text a bit clearer as to exactly which machines this device would be expected for, otherwise you might accidentally have distros add this device to their builds, which would not be a good thing.

Ok.

Quoted 1 line

What's wrong with drivers/c2port/ ? Come on, think big :)

Ok. Thanks! I'll repost the code ASAP.

Ciao,

Rodolfo

Signature · 4 lines
GNU/Linux Solutions                  e-mail: [email protected]
Linux Device Driver                          [email protected]
Embedded Systems                     phone:  +39 349 2432127
UNIX programming                     skype:  rodolfo.giometti
#6 lore raw

Re: [PATCH 1/1] Add c2 port support.

Quoted 6 lines · Rodolfo Giometti
Quoted 1 line · Greg KH

But you aren't submitting any clients here, right? Are you planning to?

Currently not, but I have 2 clients for my custom boards... maybe I can add one of them which uses an x86 IO port to do the job.

Well, having a "core" with no clients doesn't make much sense, so you should probably post some users of this code, otherwise why even have it?

thanks,

greg k-h

#7 lore raw

Re: [PATCH 1/1] Add c2 port support.

Quoted 3 lines · Greg KH

Well, having a "core" with no clients doesn't make much sense, so you should probably post some users of this code, otherwise why even have it?

Ok, I'll post at least the x86 client. However I posted the core in case someone may need it. ;)

Ciao,

Rodolfo

Signature · 4 lines
GNU/Linux Solutions                  e-mail: [email protected]
Linux Device Driver                          [email protected]
Embedded Systems                     phone:  +39 349 2432127
UNIX programming                     skype:  rodolfo.giometti
#8 lore raw
In reply to Rodolfo Giometti
Quoted 12 lines · Rodolfo Giometti

C2 port implements a two wire serial communication protocol (bit banging) designed to enable in-system programming, debugging, and boundary-scan testing on low pin-count Silicon Labs devices.

Main references are at Silicon Laboratories site:

* AN127: FLASH Programming via the C2 Interface
http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/Small_Form_Factor/en/an127.pdf

* C2 Specification
http://www.silabs.com/public/documents/tpub_doc/spec/Microcontrollers/en/C2spec.pdf

Quoted 7 lines

Currently this code supports only flash programming through sysfs interface but extensions shoud be easy to add.

I know that this (proposal) patch may be incomplete but I'd like to know what you are thinking about it before continuing further. For example I'd like to know if should I put the C2 port core here or into proper subdirectory of linux/drivers/misc/ where clients can be placed also.

Hm, I seem to be missing the patch here :(

thanks,

greg k-h