Skip to contentSkip to conversation

16C552 parallel port initialization problems in u-boot

U-Boot-Users Sam Song 1 participant 1 message Mar 13, 2004

lore
Share & tools
lore

Sam Song

author
#0 lore raw

Hi,

I am working adding support of parallel port of ST16C552 in u-boot but have some weird initialization problems.So I list my related programs and questions as follows for any further help.

***Problems***
1. How come board_parallel_init became invalid when I put it in lib_ppc/board.c board_init_f() for debugging?

2. Why could I only get 0x00 or 0xff initialization results for the parallel port-PD0-PD7 when I changed par_port->pr1 in ns16552.c as different values like 0x55 or 0xAA?It seemed that the PR register only accpected 0x00 or 0xff as it's first value.But I could change it's value correctly by u-boot command.

3. What's meaning of "__attribute__ ((packed))" in NS16552 structure definition?I copyed it from ns16550.h but don't understand it's function.

***16C552 parallel port register content*** u-boot>md fa010000
fa010000: ff67e0e0 ff67e0e0 ff67e0e0 ff67e0e0 .g
fa010010: ff67e0e0 ff67e0e0 ff67e0e0 ff67e0e0 .g
u-boot>mm.b fa010000
fa010000: ff ? 55
fa010001: 67 ? 55
fa010002: e0 ? e4
fa010003: e4 ? e4
fa010004: 55 ? .
u-boot>md fa010000
fa010000: 5567e4e4 5567e4e4 5567e4e4 5567e4e4 Ug.
fa010010: 5567e4e4 5567e4e4 5567e4e4 5567e4e4 Ug.
u-boot>

When setting 'par_port->pr1 = 0xAA' ,it displayed:
fa010000: ff67e0e0 ff67e0e0 ff67e0e0 ff67e0e0

***Program***
[MYBOARD.h]
/*-------------------------------------
* NS16552 PRINTER PORT Configuration
*/

#define CFG_PORT_BASE 0xFA010000
#define CFG_NS16552
#define CONFIG_PARALLEL
#define CFG_NS16552_PORT CFG_PORT_BASE

#ifdef CONFIG_PARALLEL
#define CFG_BR6_PRELIM 0xFA010401 /* REGISTER CS6 */ #define CFG_OR6_PRELIM 0xFFFF0040
#endif

[include/ns16552.h]

#ifdef CONFIG_PARALLEL /* Sam */
struct NS16552 {

        unsigned short pr0;             /* 0 */
        unsigned short sr;              /* 1 */
        unsigned short com;             /* 2 */

} __attribute__ ((packed));
#endif

#define pr1 pr0
#define iosel sr /* Sam */
#define con com

void NS16552_init (NS16552_t par_port);

[driver/ns16552.c]

#include <config.h>
#ifdef CFG_NS16552
#include <ns16552.h>

void NS16552_init (NS16552_t par_port)

{
        par_port->iosel = 0x55;
        par_port->pr1 = 0xFF;
        par_port->con = (CON_LOGIC3 | CON_LOGIC2 |

~CON_INTP | CON_INIT );

}
#endif

[driver/parallel.c]

#include <ns16552.h>

static NS16552_t port = (NS16552_t) CFG_NS16552_PORT;

int parallel_init (void)

{
       NS16552_init (port);
       return (0);
}

[lib_ppc/board.c]

#include <config.h>

--In board_init_r()---

#if defined(CONFIG_MYBOARD)
        board_parallel_init();

#endif

Sorry for disturbing your nice weekend by many questions!Thanks in advance!

Sam

_________________________________________________________
Do You Yahoo!?
??????????????????60???????
http://cn.rd.yahoo.com/mail_cn/tag/?http://cn.mail.yahoo.com