xref: /linux/Documentation/misc-devices/c2port.rst (revision 433b1b0d75c717d7a563b42423ce63c9a58a07b5)
1*433b1b0dSMauro Carvalho Chehab.. SPDX-License-Identifier: GPL-2.0
2*433b1b0dSMauro Carvalho Chehab.. include:: <isonum.txt>
3*433b1b0dSMauro Carvalho Chehab
4*433b1b0dSMauro Carvalho Chehab===============
54e17e1dbSRodolfo GiomettiC2 port support
6*433b1b0dSMauro Carvalho Chehab===============
74e17e1dbSRodolfo Giometti
84e17e1dbSRodolfo Giometti(C) Copyright 2007 Rodolfo Giometti <giometti@enneenne.com>
94e17e1dbSRodolfo Giometti
104e17e1dbSRodolfo GiomettiThis program is free software; you can redistribute it and/or modify
114e17e1dbSRodolfo Giomettiit under the terms of the GNU General Public License as published by
124e17e1dbSRodolfo Giomettithe Free Software Foundation; either version 2 of the License, or
134e17e1dbSRodolfo Giometti(at your option) any later version.
144e17e1dbSRodolfo Giometti
154e17e1dbSRodolfo GiomettiThis program is distributed in the hope that it will be useful,
164e17e1dbSRodolfo Giomettibut WITHOUT ANY WARRANTY; without even the implied warranty of
174e17e1dbSRodolfo GiomettiMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
184e17e1dbSRodolfo GiomettiGNU General Public License for more details.
194e17e1dbSRodolfo Giometti
204e17e1dbSRodolfo Giometti
214e17e1dbSRodolfo Giometti
224e17e1dbSRodolfo GiomettiOverview
234e17e1dbSRodolfo Giometti--------
244e17e1dbSRodolfo Giometti
254e17e1dbSRodolfo GiomettiThis driver implements the support for Linux of Silicon Labs (Silabs)
264e17e1dbSRodolfo GiomettiC2 Interface used for in-system programming of micro controllers.
274e17e1dbSRodolfo Giometti
284e17e1dbSRodolfo GiomettiBy using this driver you can reprogram the in-system flash without EC2
294e17e1dbSRodolfo Giomettior EC3 debug adapter. This solution is also useful in those systems
304e17e1dbSRodolfo Giomettiwhere the micro controller is connected via special GPIOs pins.
314e17e1dbSRodolfo Giometti
324e17e1dbSRodolfo GiomettiReferences
334e17e1dbSRodolfo Giometti----------
344e17e1dbSRodolfo Giometti
3593431e06SAlexander A. KlimovThe C2 Interface main references are at (https://www.silabs.com)
364e17e1dbSRodolfo GiomettiSilicon Laboratories site], see:
374e17e1dbSRodolfo Giometti
384e17e1dbSRodolfo Giometti- AN127: FLASH Programming via the C2 Interface at
3993431e06SAlexander A. Klimov  https://www.silabs.com/Support Documents/TechnicalDocs/an127.pdf
404e17e1dbSRodolfo Giometti
414e17e1dbSRodolfo Giometti- C2 Specification at
4293431e06SAlexander A. Klimov  https://www.silabs.com/pages/DownloadDoc.aspx?FILEURL=Support%20Documents/TechnicalDocs/an127.pdf&src=SearchResults
434e17e1dbSRodolfo Giometti
444e17e1dbSRodolfo Giomettihowever it implements a two wire serial communication protocol (bit
454e17e1dbSRodolfo Giomettibanging) designed to enable in-system programming, debugging, and
464e17e1dbSRodolfo Giomettiboundary-scan testing on low pin-count Silicon Labs devices. Currently
474e17e1dbSRodolfo Giomettithis code supports only flash programming but extensions are easy to
484e17e1dbSRodolfo Giomettiadd.
494e17e1dbSRodolfo Giometti
504e17e1dbSRodolfo GiomettiUsing the driver
514e17e1dbSRodolfo Giometti----------------
524e17e1dbSRodolfo Giometti
534e17e1dbSRodolfo GiomettiOnce the driver is loaded you can use sysfs support to get C2port's
54*433b1b0dSMauro Carvalho Chehabinfo or read/write in-system flash::
554e17e1dbSRodolfo Giometti
564e17e1dbSRodolfo Giometti  # ls /sys/class/c2port/c2port0/
574e17e1dbSRodolfo Giometti  access            flash_block_size  flash_erase       rev_id
584e17e1dbSRodolfo Giometti  dev_id            flash_blocks_num  flash_size        subsystem/
594e17e1dbSRodolfo Giometti  flash_access      flash_data        reset             uevent
604e17e1dbSRodolfo Giometti
614e17e1dbSRodolfo GiomettiInitially the C2port access is disabled since you hardware may have
624e17e1dbSRodolfo Giomettisuch lines multiplexed with other devices so, to get access to the
63*433b1b0dSMauro Carvalho ChehabC2port, you need the command::
644e17e1dbSRodolfo Giometti
654e17e1dbSRodolfo Giometti  # echo 1 > /sys/class/c2port/c2port0/access
664e17e1dbSRodolfo Giometti
674e17e1dbSRodolfo Giomettiafter that you should read the device ID and revision ID of the
68*433b1b0dSMauro Carvalho Chehabconnected micro controller::
694e17e1dbSRodolfo Giometti
704e17e1dbSRodolfo Giometti  # cat /sys/class/c2port/c2port0/dev_id
714e17e1dbSRodolfo Giometti  8
724e17e1dbSRodolfo Giometti  # cat /sys/class/c2port/c2port0/rev_id
734e17e1dbSRodolfo Giometti  1
744e17e1dbSRodolfo Giometti
754e17e1dbSRodolfo GiomettiHowever, for security reasons, the in-system flash access in not
76*433b1b0dSMauro Carvalho Chehabenabled yet, to do so you need the command::
774e17e1dbSRodolfo Giometti
784e17e1dbSRodolfo Giometti  # echo 1 > /sys/class/c2port/c2port0/flash_access
794e17e1dbSRodolfo Giometti
80*433b1b0dSMauro Carvalho ChehabAfter that you can read the whole flash::
814e17e1dbSRodolfo Giometti
824e17e1dbSRodolfo Giometti  # cat /sys/class/c2port/c2port0/flash_data > image
834e17e1dbSRodolfo Giometti
84*433b1b0dSMauro Carvalho Chehaberase it::
854e17e1dbSRodolfo Giometti
864e17e1dbSRodolfo Giometti  # echo 1 > /sys/class/c2port/c2port0/flash_erase
874e17e1dbSRodolfo Giometti
88*433b1b0dSMauro Carvalho Chehaband write it::
894e17e1dbSRodolfo Giometti
904e17e1dbSRodolfo Giometti  # cat image > /sys/class/c2port/c2port0/flash_data
914e17e1dbSRodolfo Giometti
92*433b1b0dSMauro Carvalho Chehabafter writing you have to reset the device to execute the new code::
934e17e1dbSRodolfo Giometti
944e17e1dbSRodolfo Giometti  # echo 1 > /sys/class/c2port/c2port0/reset
95