@@ -17,8 +17,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-/* Driver for the SI-Prog like hardware by Lancos.com.
- * See http://www.lancos.com/siprogsch.html for schematics and instructions.
+/* Driver for the SI-Prog like hardware and for the AJAWe serial programmer.
+ *
+ * See http://www.lancos.com/siprogsch.html for SI-Prog schematics and instructions.
+ * See http://www.ajawe.pl/ajawe0208.htm for AJAWe serial programmer documentation.
*/
#include <stdlib.h>
@@ -27,29 +29,45 @@
#include "flash.h"
#include "programmer.h"
-/* We have:
+/* We have, for SI-Prog like hardware:
- MOSI -----> DTR
- MISO -----> CTS
- SCK --+--> RTS
- +--> DSR
- CS# -----> TXD
+ MOSI <-------< DTR
+ MISO >-------> CTS
+ SCK <---+---< RTS
+ +---> DSR
+ CS# <-------< TXD
+
+and for the AJAWe serial programmer:
+
+ MOSI <-------< DTR
+ MISO >-------> CTS
+ SCK <-------< RTS
+ CS# <-------< TXD
+
+ DCE >-------> DSR
*/
enum pony_type {
TYPE_SI_PROG,
TYPE_SERBANG,
+ TYPE_AJAWE
};
/* The hardware programmer used. */
static enum pony_type pony_type = TYPE_SI_PROG;
+/* Pins for master->slave direction */
+static int pony_negate_cs = 1;
+static int pony_negate_sck = 0;
+static int pony_negate_mosi = 0;
+/* Pins for slave->master direction */
+static int pony_negate_miso = 0;
+
static void pony_bitbang_set_cs(int val)
{
- if (pony_type == TYPE_SI_PROG)
+ if (pony_negate_cs)
{
- /* CS# is negated by the SI-Prog programmer. */
val ^= 1;
}
sp_set_pin(PIN_TXD, val);
@@ -57,11 +75,19 @@
static void pony_bitbang_set_sck(int val)
{
+ if (pony_negate_sck)
+ {
+ val ^= 1;
+ }
sp_set_pin(PIN_RTS, val);
}
static void pony_bitbang_set_mosi(int val)
{
+ if (pony_negate_mosi)
+ {
+ val ^= 1;
+ }
sp_set_pin(PIN_DTR, val);
}
@@ -71,9 +97,8 @@
tmp = sp_get_pin(PIN_CTS);
- if (pony_type == TYPE_SERBANG)
+ if (pony_negate_miso)
{
- /* MISO is negated by the SERBANG programmer. */
tmp ^= 1;
}
return tmp;
@@ -98,7 +123,7 @@
arg = extract_programmer_param("dev");
if (arg && strlen(arg)) {
- sp_fd = sp_openserport( arg, 9600 );
+ sp_fd = sp_openserport(arg, 9600);
have_device++;
}
free(arg);
@@ -118,8 +143,10 @@
if (arg) {
if (!strcasecmp( arg, "serbang")) {
pony_type = TYPE_SERBANG;
- } else if (!strcasecmp( arg, "si_prog") ) {
+ } else if (!strcasecmp( arg, "si_prog")) {
pony_type = TYPE_SI_PROG;
+ } else if (!strcasecmp( arg, "ajawe")) {
+ pony_type = TYPE_AJAWE;
} else {
msg_perr("Error: Invalid programmer type specified.\n");
free(arg);
@@ -128,28 +155,71 @@
}
free(arg);
- msg_pdbg("Using the %s programmer.\n", ((pony_type == TYPE_SI_PROG ) ? "SI-Prog" : "SERBANG"));
/*
- * Detect if there is a SI-Prog compatible programmer connected.
+ * Configure the serial port pins, depending in the used programmer.
+ */
+ switch (pony_type) {
+ case TYPE_SI_PROG:
+ msg_pdbg("Using SI-Prog programmer pinout.\n");
+ /* Bits for master->slave direction */
+ pony_negate_cs = 1;
+ pony_negate_sck = 0;
+ pony_negate_mosi = 0;
+ /* Bits for slave->master direction */
+ pony_negate_miso = 0;
+ break;
+ case TYPE_SERBANG:
+ msg_pdbg("Using SERBANG programmer pinout.\n");
+ /* Bits for master->slave direction */
+ pony_negate_cs = 0;
+ pony_negate_sck = 0;
+ pony_negate_mosi = 0;
+ /* Bits for slave->master direction */
+ pony_negate_miso = 1;
+ break;
+ case TYPE_AJAWE:
+ msg_pdbg("Using AJAWe programmer pinout.\n");
+ /* Bits for master->slave direction */
+ pony_negate_cs = 1;
+ pony_negate_sck = 1;
+ pony_negate_mosi = 1;
+ /* Bits for slave->master direction */
+ pony_negate_miso = 1;
+ break;
+ }
+
+ /*
+ * Detect if there is a compatible hardware programmer connected.
*/
pony_bitbang_set_cs(1);
+ pony_bitbang_set_sck(1);
pony_bitbang_set_mosi(1);
- /* We toggle SCK while we keep MOSI and CS# on. */
- for (i = 1; i <= 10; ++i) {
- data_out = i & 1;
- sp_set_pin(PIN_RTS, data_out);
- programmer_delay( 1000 );
+ if (pony_type == TYPE_AJAWE)
+ {
+ /* The AJAWe serial programmer just have DSR off when it is active. */
data_in = sp_get_pin(PIN_DSR);
- if (data_out != data_in) {
+ if(data_in) {
have_prog = 0;
- break;
+ }
+ } else {
+ /* We toggle SCK while we keep MOSI and CS# on. */
+ for (i = 1; i <= 10; ++i) {
+ data_out = i & 1;
+ sp_set_pin(PIN_RTS, data_out);
+ programmer_delay( 1000 );
+ data_in = sp_get_pin(PIN_DSR);
+
+ if (data_out != data_in) {
+ have_prog = 0;
+ break;
+ }
}
}
if (!have_prog) {
- msg_perr( "No SI-Prog compatible hardware detected.\n" );
+ msg_perr("No compatible %s programmer detected.\n", ((pony_type == TYPE_AJAWE) ? "AJAWe" : "SI-Prog"));
return 1;
}
@@ -511,7 +511,7 @@
msg_ginfo("\nSupported devices for the %s programmer:\n",
programmer_table[PROGRAMMER_PONY_SPI].name);
/* FIXME */
- msg_ginfo("SI-Prog and SERBANG serial port programmer\n");
+ msg_ginfo("SI-Prog, SERBANG and AJAWe serial port programmer\n");
#endif
#if CONFIG_NICINTEL == 1
msg_ginfo("\nSupported devices for the %s programmer:\n",
@@ -219,6 +219,7 @@
GetCommModemStatus(sp_fd, &ctl);
#else
int ctl;
+
s = (pin == PIN_CTS) ? TIOCM_CTS : TIOCM_DSR;
ioctl(sp_fd, TIOCMGET, &ctl);
#endif
Hello, There is a new patch for pony_spi, to add support for a new serial programmer, produced by AJAWe. For another hardware details: http://www.ajawe.pl/ajawe0208.htm http://www.ajawe.pl/files/0208_R_DOK.pdf BTW, the site and documentation is in Polish language, I believe, but it is very easy to understand its schematics and what they sell... All the best, Virgil-Adrian. Signed-off-by: Virgil-Adrian Teaca <darkstarlinux@gmail.com>