|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: Q2 M N$ [6 p, h
#include <linux/init.h># N8 S! q6 T( x) J$ v+ {/ g! G
#include <linux/module.h>
8 |6 @* n+ a/ _, ^6 `6 r0 ~8 \#include <linux/kernel.h>) e3 D6 o0 p- r$ }7 Y
#include <linux/types.h>
( k i5 Y# Z# O#include <linux/gpio.h>
0 M6 K6 {- q+ B, a/ N/ q7 S3 c6 {" [#include <linux/leds.h>+ D# p, k& ~8 C
#include <linux/platform_device.h>
: ]8 j" p- b. P) s) L Z& M: k
7 M. Q' S. q+ g; t#include <asm/mach-types.h>* q" B! [- Y8 l4 Z6 l. Y l ]
#include <asm/mach/arch.h>* y0 i8 G7 D1 r; s3 [+ b1 e9 y
#include <mach/da8xx.h>
) Q' I. d4 m* D" U8 |4 o#include <mach/mux.h>" }: Z% F+ D$ A1 n! X0 ?
3 n( Z* b6 p* k0 i/ h" U#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" j: T8 b3 H9 w3 R* g: d7 ?
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 `) ^( T0 f# d1 H' z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" @8 e5 X' |- D. B+ X$ o
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* m- _# f2 A' Y* _
) ?) o! Y2 f/ o/* assign the tl som board LED-GPIOs*/0 t0 h# o8 w& W* w2 F
static const short da850_evm_tl_user_led_pins[] = {- h% N9 F# F" l3 H1 Q
/* These pins are definition at <mach/mux.h> file */' H* z4 O3 g! p/ `
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- Y! }- p6 h$ u -1
4 g5 k; ?* U: b+ B; M};
# @& o0 ?( t& _8 w" D. _% c2 i
# ]* }* { X' Y* e9 p6 z( pstatic struct gpio_led da850_evm_tl_leds[] = {
+ z# W- l9 b, \3 N. H p" N {3 \: O/ E7 H9 Z; n: X
.active_low = 0,# E- o8 X/ s3 K
.gpio = DA850_USER_LED0,
* X1 w' e* S( Y! o .name = "user_led0",) u9 e; [1 u' G; Z
.default_trigger = "default-on",
3 c8 g: x! d7 d7 o8 o },2 F- h' e* H% I3 a0 C, p/ P9 p
{
x' V) w2 g7 f! \( y .active_low = 0,. |6 ^1 q9 \$ G
.gpio = DA850_USER_LED1,
$ b& R- `& p% q$ V5 U .name = "user_led1",
& z& x( n: F$ l4 O! V: X3 { .default_trigger = "default-on",$ [$ g4 n% M; M7 q
},
4 z: @, ?' a8 E8 y+ B {+ y" m/ z5 {3 T. e
.active_low = 0,
! [' B; o6 D+ g .gpio = DA850_USER_LED2,+ M4 @- I6 M! r, Y% B: O4 j
.name = "user_led2",
0 F4 l! ? f9 O0 G$ e .default_trigger = "default-on",
) o* b! ~ T) J },1 q6 y- W* F' v7 w) g
{
* a8 g+ e @$ |! K( H .active_low = 0,
, Y" a0 e# S/ j4 M, i6 @2 l9 x; P4 L5 P .gpio = DA850_USER_LED3,
$ Q4 P- W2 f7 K) y/ W9 E4 S5 m3 L% i" I: o .name = "user_led3",9 U, v6 }9 ~9 e t% u
.default_trigger = "default-on",) ]' Y8 \! Q& ]& h% i- U- A8 ~% Y
},+ s) P9 i* w! x# h* b' g' B
};
; V+ T5 v m% w, p
9 i& g% j; i/ tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- b" Q: Y3 K0 d' \2 e3 p1 E* `
.leds = da850_evm_tl_leds,
7 |- C. D" r. V& d/ R. L2 I9 M0 T .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% G+ k& M0 T$ A
};. k8 t* m6 o3 C+ T$ _$ _3 j' j% n w
5 s7 l& J$ A0 v+ b, [; jstatic void led_dev_release(struct device *dev)
+ S8 H! P! R4 u! I# A{
6 ]7 i* o8 N p- @};- r4 d( H% U- n/ t" H: j
6 s4 }) ?8 [# a: Qstatic struct platform_device da850_evm_tl_leds_device = {
5 w, Q* C1 n5 t! b/ _& Q5 O .name = "leds-gpio",
9 o# n& i, @4 q# U3 t& ^ .id = 1,1 w/ G/ t) n- Y5 v5 q6 {9 h
.dev = {
: u) ^) g* n, D .platform_data = &da850_evm_tl_leds_pdata,- n( |1 b$ X- P1 V
.release = led_dev_release,
5 g7 R' Q8 k6 _; v }
& }- h: e x U0 x% y$ X8 Z};/ x) G9 p D+ h; M
" Y* w6 f: F, F0 }8 r/ v
static int __init led_platform_init(void); K6 X# L* U' L0 C; g% K" \
{
7 L3 ~) U/ X% x" o2 J2 R int ret;
3 d1 V( w- a& L, P7 ~% v, a+ V# N#if 0
' f8 s# y0 m& W2 w" c' I# s6 G1 q4 h ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 g7 J3 z) ~3 R% ]0 ?
if (ret) v* x" Z+ I8 g/ C: {; E
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 K. U& r& \1 ]+ c "%d\n", ret);
3 _8 q' r3 g4 [) I- {% U#endif
* x2 N% ?; u: V; y# e/ ] ret = platform_device_register(&da850_evm_tl_leds_device);
( K i4 Y" ?9 {& B& e& h/ J if (ret)
- |% `6 E) E2 h1 I1 u pr_warning("Could not register som GPIO expander LEDS");
+ |( w3 n& i; n3 E$ F( g else4 Z h1 E: S, Z8 p% S" [7 A; H' I _2 m
printk(KERN_INFO "LED register sucessful!\n");% t# e4 Y( S" A( Y- K" h! k
$ d M# [. s _' Y; y' A, b8 E3 M7 @0 Q return ret;
% `5 c0 z H* }9 J4 ]% r}
( W# R. i: L3 y$ g- ^
! N$ ~" E( N0 p. D) a8 s/ S/ a; ystatic void __exit led_platform_exit(void)4 W- J" h3 F# e
{3 m) `" h U8 O6 H b
platform_device_unregister(&da850_evm_tl_leds_device);
+ H5 ?* k; v+ a6 }& C
0 a4 K, }7 j/ e: C' S printk(KERN_INFO "LED unregister!\n");
* W! O% c6 X4 R( j2 M5 m}" A. t9 v0 I/ l, a3 V8 Q
& _: {" o0 ~% O9 A
module_init(led_platform_init);
$ E2 B8 m4 y2 d. a$ G# ~) z# ]4 bmodule_exit(led_platform_exit);
) `6 n; e* y" N) N% n% R c' n* w# z. k2 `
MODULE_DESCRIPTION("Led platform driver");; a: a/ j( C9 U. u' o, C2 U
MODULE_AUTHOR("Tronlong");
: R/ e: J: P7 ?8 ^MODULE_LICENSE("GPL");2 U* V6 x1 N2 \
- ^1 W2 c4 e" z- b1 I G
|
|