|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 |: b0 K3 a/ j6 P) w; d
#include <linux/init.h>
& b$ C9 _% z1 ~#include <linux/module.h>* F! F, @7 v; i
#include <linux/kernel.h>' J$ C4 u K* `9 _( V
#include <linux/types.h>8 i+ n( G2 }3 b( p/ ~* h! ^
#include <linux/gpio.h>" \7 X* t7 g1 N- k) B ?
#include <linux/leds.h>
& q7 ~' p+ |. Y' e) d, m6 n- ]#include <linux/platform_device.h>: f2 N6 x5 g5 n
; D( O; l; K5 o- u% b5 j2 x
#include <asm/mach-types.h>! C# A# X' P5 K- f! ]
#include <asm/mach/arch.h>, Z, e, `" ]+ D/ o+ K: ?
#include <mach/da8xx.h>9 f7 U+ [6 G4 r5 e4 N
#include <mach/mux.h>
/ T) W: ^3 |2 G7 v" H% C7 b
]1 d5 E! \3 W5 {6 i#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
`- y4 q* _* H' j) n+ }- }* `#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 Y: k. O* x% Z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, t: }1 X7 `1 Q( O" U8 o#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) y8 I( Z* Q! h! l+ n# W9 L
. \% U: w: n3 r% f; ]7 o/ C K! ?/* assign the tl som board LED-GPIOs*/0 o3 P# u! {- Q% L
static const short da850_evm_tl_user_led_pins[] = {
9 K9 }, h- p- v' }, ~9 ?5 O( J /* These pins are definition at <mach/mux.h> file */1 j& M) i9 `) ^: ]# M: H* e, C% l
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' d7 g) m/ w& [8 b0 V/ r4 x) d8 D7 P
-1
2 ]! H+ [, X; z' f) v3 v};
1 }3 F9 W# M, [/ c6 \" O3 a; g3 c, ^) O4 n; B# Y3 n
static struct gpio_led da850_evm_tl_leds[] = {
0 R2 {/ L4 Y9 r; o7 f {
' p/ G. ^6 K2 q! Y6 P .active_low = 0,
) S7 E+ y" Q) S; T! V+ x .gpio = DA850_USER_LED0,- j! Q/ E" J# t1 j, P3 r5 X
.name = "user_led0", d. l* f, {& B1 r7 i( H3 s9 A' J
.default_trigger = "default-on",
! J: R X8 @" s/ v! H },
0 s3 X- P% X9 ?, i; S {
6 j$ [8 @, _! v0 _3 L0 h .active_low = 0,8 s+ T; b0 F, O# P
.gpio = DA850_USER_LED1,
6 K8 F$ a4 q6 z* l4 D5 W .name = "user_led1",) Z/ @. }# g9 m( r: X8 G
.default_trigger = "default-on",# v+ ]! r: ]+ |4 C7 [
},
6 s/ V8 z# g' R* X' q {/ o; x' o' C3 Z! e3 m: |' }9 _( c
.active_low = 0,1 O2 i! w+ f% [
.gpio = DA850_USER_LED2,. i* r; r; C, K5 |9 m% ^, R. `( Y0 _
.name = "user_led2",
7 h+ C% r% l* {# R, A! { .default_trigger = "default-on",& d& T3 f1 `3 d" v/ R) C I
},% m1 h% A0 K/ u+ E* B; y, u; S" \ h
{% Z) G, y- q2 u; L) p
.active_low = 0,4 ?3 V: G4 m% M/ W- |0 I
.gpio = DA850_USER_LED3,$ T3 `( S; Q5 w! S5 {6 H+ Y4 w
.name = "user_led3",
. `3 s/ C* h" m4 ] .default_trigger = "default-on",
( G1 N0 M) W1 s5 h3 Z( \ },
5 `- H A8 S& i};: ]% ~3 @3 T7 ]. ?4 M
2 c( Q: u: k! g- L1 g. p* X
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; m$ \( q1 _, U% G, C# ]9 w( U .leds = da850_evm_tl_leds,' y* l1 p* q/ l0 X+ I6 @
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: k0 J5 W0 h- F- C6 S. G, n3 S9 `* {1 l};1 m- o0 V! w! P( ^% K3 f
" `1 J) X9 b1 m
static void led_dev_release(struct device *dev)) O* x x' ~. `, B" I" f8 E
{
. x2 s: B6 n5 x# {};9 P- f, d+ W$ u+ t& M# C! x+ t
0 q+ I6 Z+ L; N) Astatic struct platform_device da850_evm_tl_leds_device = {
. R. r% |3 J- E' I% O; [ .name = "leds-gpio",( V. \- j* e9 Q# ]' O" r* y
.id = 1,
2 a7 c3 F% j' u; H1 d" k( V .dev = { I/ y7 q- L+ u9 `: Q* T8 q
.platform_data = &da850_evm_tl_leds_pdata,' u* y5 x' W% l( W9 j& u
.release = led_dev_release,
) g) C+ q+ h3 d* b. a9 N }
9 G _6 Y9 e# a" K$ [) G1 H};. c1 _% {+ ~8 g; h
6 F6 h. U. i5 f9 `% H
static int __init led_platform_init(void)5 P+ k1 L" E* d3 f E7 o& x
{1 ~) Z$ n+ h; c. x: q# \
int ret;. r# d' q) @7 W' J
#if 0
0 P( a3 p; H9 n6 {+ f' ? ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); ?, c q O/ Z% o; B: S9 b3 A' u
if (ret)3 g! e3 A$ u. c
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 _# n0 o! [( e0 r8 n "%d\n", ret);* M" o: g- J" p. U. s: X: g
#endif0 r. q$ c' y9 s, @: ]$ d
ret = platform_device_register(&da850_evm_tl_leds_device);
% D7 o+ z& x( T3 i* X if (ret)
Z2 @! s4 P* Q& i pr_warning("Could not register som GPIO expander LEDS");9 s# M ~ ~* y
else, f0 g5 ]# s5 p# v
printk(KERN_INFO "LED register sucessful!\n");
; I- X1 g! B$ p* R
( p% @6 O* ]% ~. ^( c ^. U return ret;
) k9 |; b$ g% b/ _8 Y& u. h0 T: {}
# G' r: R; F2 O/ j0 M$ D7 a% N- H0 G% c
static void __exit led_platform_exit(void)
; {9 G) H$ K; ~+ z- L+ ^9 T{
& w7 }1 Q1 ` [+ D platform_device_unregister(&da850_evm_tl_leds_device);! q/ B0 \9 f2 S) l. f
3 S6 X+ [/ M8 v6 Q+ L printk(KERN_INFO "LED unregister!\n");* J, j/ V# j n8 l; c. C
}
( R# l% K! t9 V2 q% w" Q9 v, c* L/ W8 P$ y& O9 W
module_init(led_platform_init);
' D8 c9 j* y/ }/ h: Pmodule_exit(led_platform_exit);8 \- D% @4 k" u+ R' E5 K
5 ~/ b9 b6 D' }, [MODULE_DESCRIPTION("Led platform driver");- M1 i1 ?1 W2 K& b- {$ D9 k+ @/ q
MODULE_AUTHOR("Tronlong");' Z) M7 R5 D x
MODULE_LICENSE("GPL");0 Q8 a$ t( {# P& K+ L
5 J6 y& R8 C- a2 F1 z' {4 o8 w0 X
|
|