Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
reform-boundary-uboot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jack Humbert
reform-boundary-uboot
Commits
8e234e33
Commit
8e234e33
authored
14 years ago
by
Anatolij Gustschin
Committed by
Wolfgang Denk
14 years ago
Browse files
Options
Downloads
Patches
Plain Diff
mpc5121: add PSC serial communication routines
Signed-off-by:
Anatolij Gustschin
<
agust@denx.de
>
parent
e3b28e67
Loading
Loading
Loading
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arch/powerpc/cpu/mpc512x/serial.c
+87
-0
87 additions, 0 deletions
arch/powerpc/cpu/mpc512x/serial.c
include/serial.h
+7
-0
7 additions, 0 deletions
include/serial.h
with
94 additions
and
0 deletions
arch/powerpc/cpu/mpc512x/serial.c
+
87
−
0
View file @
8e234e33
...
...
@@ -401,3 +401,90 @@ int serial_getcts(void)
return
serial_getcts_dev
(
CONFIG_PSC_CONSOLE
);
}
#endif
/* CONFIG_PSC_CONSOLE */
#if defined(CONFIG_SERIAL_MULTI)
#include
<stdio_dev.h>
/*
* Routines for communication with serial devices over PSC
*/
/* Bitfield for initialized PSCs */
static
unsigned
int
initialized
;
struct
stdio_dev
*
open_port
(
int
num
,
int
baudrate
)
{
struct
stdio_dev
*
port
;
char
env_var
[
16
];
char
env_val
[
10
];
char
name
[
7
];
if
(
num
<
0
||
num
>
11
)
return
NULL
;
sprintf
(
name
,
"psc%d"
,
num
);
port
=
stdio_get_by_name
(
name
);
if
(
!
port
)
return
NULL
;
if
(
!
test_bit
(
num
,
&
initialized
))
{
sprintf
(
env_var
,
"psc%d_baudrate"
,
num
);
sprintf
(
env_val
,
"%d"
,
baudrate
);
setenv
(
env_var
,
env_val
);
if
(
port
->
start
())
return
NULL
;
set_bit
(
num
,
&
initialized
);
}
return
port
;
}
int
close_port
(
int
num
)
{
struct
stdio_dev
*
port
;
int
ret
;
char
name
[
7
];
if
(
num
<
0
||
num
>
11
)
return
-
1
;
sprintf
(
name
,
"psc%d"
,
num
);
port
=
stdio_get_by_name
(
name
);
if
(
!
port
)
return
-
1
;
ret
=
port
->
stop
();
clear_bit
(
num
,
&
initialized
);
return
ret
;
}
int
write_port
(
struct
stdio_dev
*
port
,
char
*
buf
)
{
if
(
!
port
||
!
buf
)
return
-
1
;
port
->
puts
(
buf
);
return
0
;
}
int
read_port
(
struct
stdio_dev
*
port
,
char
*
buf
,
int
size
)
{
int
cnt
=
0
;
if
(
!
port
||
!
buf
)
return
-
1
;
if
(
!
size
)
return
0
;
while
(
port
->
tstc
())
{
buf
[
cnt
++
]
=
port
->
getc
();
if
(
cnt
>
size
)
break
;
}
return
cnt
;
}
#endif
/* CONFIG_SERIAL_MULTI */
This diff is collapsed.
Click to expand it.
include/serial.h
+
7
−
0
View file @
8e234e33
...
...
@@ -92,4 +92,11 @@ extern int usbtty_tstc(void);
#endif
/* CONFIG_USB_TTY */
#if defined(CONFIG_MPC512X) && defined(CONFIG_SERIAL_MULTI)
extern
struct
stdio_dev
*
open_port
(
int
num
,
int
baudrate
);
extern
int
close_port
(
int
num
);
extern
int
write_port
(
struct
stdio_dev
*
port
,
char
*
buf
);
extern
int
read_port
(
struct
stdio_dev
*
port
,
char
*
buf
,
int
size
);
#endif
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment