Kconfig: use named pins for SD select and enable signals.

This commit is contained in:
Serge Vakulenko
2015-09-08 22:17:10 -07:00
parent c631ae5d43
commit 355ad339ef
28 changed files with 277 additions and 251 deletions

View File

@@ -93,27 +93,28 @@ struct idlst {
};
struct device {
int d_type; /* CONTROLLER, DEVICE, bus adaptor */
struct device *d_conn; /* what it is connected to */
char *d_name; /* name of device (e.g. rk11) */
struct idlst *d_vec; /* interrupt vectors */
int d_pri; /* interrupt priority */
int d_addr; /* address of csr */
int d_unit; /* unit number */
int d_drive; /* drive number */
int d_slave; /* slave number */
#define QUES -1 /* -1 means '?' */
#define UNKNOWN -2 /* -2 means not set yet */
int d_dk; /* if init 1 set to number for iostat */
int d_flags; /* flags for device init */
char *d_port; /* io port base manifest constant */
int d_portn; /* io port base (if number not manifest) */
char *d_mask; /* interrupt mask */
int d_maddr; /* io memory base */
int d_msize; /* io memory size */
int d_drq; /* DMA request */
int d_irq; /* interrupt request */
struct device *d_next; /* Next one in list */
int d_type; /* CONTROLLER, DEVICE, bus adaptor */
struct device *d_conn; /* what it is connected to */
char *d_name; /* name of device (e.g. rk11) */
struct idlst *d_vec; /* interrupt vectors */
int d_pri; /* interrupt priority */
int d_addr; /* address of csr */
int d_unit; /* unit number */
int d_drive; /* drive number */
int d_slave; /* slave number */
#define QUES -1 /* -1 means '?' */
#define UNKNOWN -2 /* -2 means not set yet */
int d_flags; /* flags for device init */
char *d_port; /* io port base manifest constant */
char *d_mask; /* interrupt mask */
int d_maddr; /* io memory base */
int d_msize; /* io memory size */
int d_drq; /* DMA request */
int d_irq; /* interrupt request */
struct device *d_next; /* Next one in list */
#define MAXPINS 32 /* max number of pins */
short d_pins[MAXPINS]; /* pins assigned */
int d_npins; /* pin count */
};
struct config {

View File

@@ -16,7 +16,6 @@
%token CPU
%token CSR
%token DEVICE
%token DISK
%token DRIVE
%token DST
%token DUMPS
@@ -25,20 +24,19 @@
%token HZ
%token LDSCRIPT
%token MAJOR
%token MASTER
%token MAXUSERS
%token MINOR
%token MINUS
%token ON
%token OPTIONS
%token MAKEOPTIONS
%token PINS
%token PRIORITY
%token PSEUDO_DEVICE
%token SERVICE
%token ROOT
%token SEMICOLON
%token SEQUENTIAL
%token SIZE
%token SLAVE
%token SWAP
%token TIMEZONE
%token TRACE
@@ -47,6 +45,7 @@
%token <str> ID
%token <val> NUMBER
%token <val> FPNUMBER
%token <val> PIN
%type <str> Save_id
%type <str> Opt_value
@@ -435,25 +434,19 @@ Device_spec:
DEVICE Dev_name Dev_info Int_spec
= { cur.d_type = DEVICE; }
|
MASTER Dev_name Dev_info Int_spec
= { cur.d_type = MASTER; }
|
DISK Dev_name Dev_info Int_spec
= { cur.d_dk = 1; cur.d_type = DEVICE; }
|
CONTROLLER Dev_name Dev_info Int_spec
= { cur.d_type = CONTROLLER; }
|
PSEUDO_DEVICE Init_dev Dev
SERVICE Init_dev Dev
= {
cur.d_name = $3;
cur.d_type = PSEUDO_DEVICE;
cur.d_type = SERVICE;
}
|
PSEUDO_DEVICE Init_dev Dev NUMBER
SERVICE Init_dev Dev NUMBER
= {
cur.d_name = $3;
cur.d_type = PSEUDO_DEVICE;
cur.d_type = SERVICE;
cur.d_slave = $4;
}
;
@@ -464,6 +457,11 @@ Dev_name:
cur.d_name = $2;
cur.d_unit = $3;
}
|
Init_dev Dev
= {
cur.d_name = $2;
}
;
Init_dev:
@@ -497,17 +495,10 @@ Info:
DRIVE NUMBER
= { cur.d_drive = $2; }
|
SLAVE NUMBER
= {
if (cur.d_conn != 0 &&
cur.d_conn->d_type == MASTER)
cur.d_slave = $2;
else
yyerror("can't specify slave--not to master");
}
|
FLAGS NUMBER
= { cur.d_flags = $2; }
|
PINS Pin_list
;
Int_spec:
@@ -533,6 +524,14 @@ Id_list:
a->id = $1; a->id_next = $2; $$ = a;
}
;
Pin_list:
PIN
= { cur.d_pins[cur.d_npins++] = $1; }
|
PIN COMMA Pin_list
= { cur.d_pins[cur.d_npins++] = $1; }
;
%%
void yyerror(s)
@@ -654,7 +653,7 @@ connect(dev, num)
for (dp = dtab; dp != 0; dp = dp->d_next) {
if ((num != dp->d_unit) || !eq(dev, dp->d_name))
continue;
if (dp->d_type != CONTROLLER && dp->d_type != MASTER) {
if (dp->d_type != CONTROLLER) {
(void) sprintf(errbuf,
"%s connected to non-controller", dev);
yyerror(errbuf);
@@ -736,15 +735,15 @@ void init_dev(dp)
dp->d_type = DEVICE;
dp->d_conn = 0;
dp->d_vec = 0;
dp->d_addr = dp->d_flags = dp->d_dk = 0;
dp->d_addr = dp->d_flags;
dp->d_pri = -1;
dp->d_slave = dp->d_drive = dp->d_unit = UNKNOWN;
dp->d_port = (char *)0;
dp->d_portn = 0;
dp->d_irq = -1;
dp->d_drq = -1;
dp->d_maddr = 0;
dp->d_msize = 0;
dp->d_npins = 0;
dp->d_mask = "null";
}

View File

@@ -58,7 +58,6 @@ static struct kt key_words[] = {
{ "cpu", CPU },
{ "csr", CSR },
{ "device", DEVICE },
{ "disk", DISK },
{ "drive", DRIVE },
{ "dst", DST },
{ "dumps", DUMPS },
@@ -68,17 +67,17 @@ static struct kt key_words[] = {
{ "architecture", ARCHITECTURE },
{ "major", MAJOR },
{ "makeoptions", MAKEOPTIONS },
{ "master", MASTER },
{ "maxusers", MAXUSERS },
{ "minor", MINOR },
{ "on", ON },
{ "options", OPTIONS },
{ "pin", PINS },
{ "pins", PINS },
{ "priority", PRIORITY },
{ "pseudo-device", PSEUDO_DEVICE },
{ "root", ROOT },
{ "sequential", SEQUENTIAL },
{ "service", SERVICE },
{ "size", SIZE },
{ "slave", SLAVE },
{ "swap", SWAP },
{ "tape", DEVICE },
{ "timezone", TIMEZONE },
@@ -104,7 +103,14 @@ kw_lookup(word)
}
%}
WORD [A-Za-z_][-A-Za-z_]*
PIN R[A-Z][0-9][0-9]*
%%
{PIN} {
/* Pin name from RA0 to RZ255. */
yylval.val = atoi(yytext + 2) & 0xff;
yylval.val |= (yytext[1] - 'A' + 1) << 8;
return PIN;
}
{WORD} {
int i;
@@ -138,7 +144,6 @@ WORD [A-Za-z_][-A-Za-z_]*
return NUMBER;
}
[0-9]"."[0-9]* {
double atof();
yylval.val = (int) (60 * atof(yytext) + 0.5);
return FPNUMBER;
}

View File

@@ -37,19 +37,19 @@
* build the ioconf.c file
*/
static void
pseudo_ioconf(fp)
service_ioconf(fp)
register FILE *fp;
{
register struct device *dp;
for (dp = dtab; dp != NULL; dp = dp->d_next)
if (dp->d_type == PSEUDO_DEVICE)
if (dp->d_type == SERVICE)
fprintf(fp, "extern void %sattach __P((int));\n",
dp->d_name);
fprintf(fp, "\nstruct conf_pdev conf_pdinit[] = {\n");
fprintf(fp, "\nstruct conf_pdev conf_sinit[] = {\n");
for (dp = dtab; dp != NULL; dp = dp->d_next)
if (dp->d_type == PSEUDO_DEVICE)
if (dp->d_type == SERVICE)
fprintf(fp, " { %sattach, %d },\n", dp->d_name,
dp->d_slave > 0 ? dp->d_slave : 1);
@@ -70,6 +70,7 @@ void pic32_ioconf()
{
register struct device *dp, *mp;
FILE *fp;
int i;
fp = fopen("ioconf.c", "w");
if (fp == 0) {
@@ -83,17 +84,17 @@ void pic32_ioconf()
/* print controller initialization structures */
for (dp = dtab; dp != 0; dp = dp->d_next) {
if (dp->d_type == PSEUDO_DEVICE)
if (dp->d_type == SERVICE)
continue;
fprintf(fp, "extern struct driver %sdriver;\n", dp->d_name);
}
fprintf(fp, "\nstruct conf_ctlr conf_cinit[] = {\n");
fprintf(fp, " /* driver,\t\tunit,\taddr,\t\tpri,\tflags */\n");
for (dp = dtab; dp != 0; dp = dp->d_next) {
if (dp->d_type != CONTROLLER && dp->d_type != MASTER)
if (dp->d_type != CONTROLLER)
continue;
if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) {
printf("can't specify drive/slave for %s%s\n",
if (dp->d_drive != UNKNOWN) {
printf("can't specify drive for %s%s\n",
dp->d_name, wnum(dp->d_unit));
continue;
}
@@ -109,10 +110,9 @@ void pic32_ioconf()
/* print devices connected to other controllers */
fprintf(fp, "\nstruct conf_device conf_dinit[] = {\n");
fprintf(fp,
" /* driver,\t\tctlr driver,\tunit,\tctlr,\tdrive,\tslave,\tdk,\tflags */\n");
" /* driver,\t\tctlr driver,\tunit,\tctlr,\tdrive,\tflags,\tpins */\n");
for (dp = dtab; dp != 0; dp = dp->d_next) {
if (dp->d_type == CONTROLLER || dp->d_type == MASTER ||
dp->d_type == PSEUDO_DEVICE)
if (dp->d_type == CONTROLLER || dp->d_type == SERVICE)
continue;
mp = dp->d_conn;
@@ -121,14 +121,29 @@ void pic32_ioconf()
fprintf(fp, "&%sdriver,\t%d,\t%d,\t",
mp->d_name, dp->d_unit, mp->d_unit);
} else {
fprintf(fp, "0,\t\t%d,\t0,\t",
dp->d_unit);
fprintf(fp, "0,\t\t%d,\t0,\t", dp->d_unit);
}
fprintf(fp, "%d,\t%d,\t%d,\t0x%x },\n",
dp->d_drive, dp->d_slave, dp->d_dk, dp->d_flags);
fprintf(fp, "%d,\t0x%x,\t", dp->d_drive, dp->d_flags);
if (dp->d_npins > 0) {
fprintf(fp, "{");
for (i=dp->d_npins-1; i>=0; i--) {
int bit = dp->d_pins[i] & 0xff;
int port = dp->d_pins[i] >> 8;
if (bit > 15 || port < 1 || port > 7) {
printf("R%c%u: invalid pin name\n", 'A'+port-1, bit);
exit(1);
}
fprintf(fp, "0x%x%x", port, bit);
if (i > 0)
fprintf(fp, ",");
}
fprintf(fp, "}");
} else
fprintf(fp, "{0}");
fprintf(fp, " },\n");
}
fprintf(fp, " { 0 }\n};\n");
pseudo_ioconf(fp);
service_ioconf(fp);
fclose(fp);
}
#endif

View File

@@ -212,7 +212,7 @@ nextparam:
goto invis;
for (dp = dtab; dp != 0; save_dp = dp, dp = dp->d_next)
if (eq(dp->d_name, wd)) {
if (std && dp->d_type == PSEUDO_DEVICE &&
if (std && dp->d_type == SERVICE &&
dp->d_slave <= 0)
dp->d_slave = 1;
goto nextparam;
@@ -221,7 +221,7 @@ nextparam:
dp = (struct device *) malloc(sizeof *dp);
init_dev(dp);
dp->d_name = strdup(wd);
dp->d_type = PSEUDO_DEVICE;
dp->d_type = SERVICE;
dp->d_slave = 1;
if (save_dp)
save_dp->d_next = dp;