|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% w4 ?2 v8 I6 Y; @#include <linux/init.h>
. w" f o# S3 _3 G, ]#include <linux/module.h>
+ j7 H2 [4 l! g( c+ u! \#include <linux/kernel.h>: \/ E2 `9 O) O: c8 D) l, y* E. `
#include <linux/types.h>
6 Y, c9 [( r4 M) [! H6 _# ^0 T/ ~#include <linux/gpio.h>
4 I, o! T( ]( ^4 D+ s, @# w2 V# E#include <linux/leds.h>$ m9 i8 {$ o' n C
#include <linux/platform_device.h>
3 ~. B' v& |' S, |3 H' K4 o* K2 K# K" h6 w5 v
#include <asm/mach-types.h>) J" V! O8 z0 _& Y5 O
#include <asm/mach/arch.h>
% k9 |2 l3 M* j) Z6 q$ o* }$ J$ m#include <mach/da8xx.h>! t, v" ]5 q% [$ L9 _* R$ ]1 ~) k
#include <mach/mux.h>) n4 I* h, Z, H0 x) C, d& V
% f, J" w5 z' g7 w2 E+ Y1 @
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# p4 B0 [: c2 }0 A#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 l, _8 a! `$ D' L
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 W, M7 V: _8 R: W [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). g" X) x3 }% X1 w; X/ }2 k
6 y6 c! X# I& j: a/ I$ ?2 T+ [/ K/* assign the tl som board LED-GPIOs*/
z- b: `5 ?# Xstatic const short da850_evm_tl_user_led_pins[] = {
{8 n$ A6 }$ j' j4 a /* These pins are definition at <mach/mux.h> file *// P& X. H' _ z) E6 J
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) s W, f0 k/ v7 H, z8 q0 K. d7 ^. Z
-1
- h% o( c- m! C% R6 A};
/ N* O& ^/ r% g6 E8 q @
4 H: W0 n# \' N; Y. m. Kstatic struct gpio_led da850_evm_tl_leds[] = {
" l+ J% J# }6 Z- W3 Q {% U; }2 P; S0 |5 p
.active_low = 0,
/ K9 H1 j% a( M# v) l( Q .gpio = DA850_USER_LED0,
; i) E8 A4 Y8 B: v0 c .name = "user_led0",$ z' |+ Z! d3 e; h+ X* K
.default_trigger = "default-on",6 _0 Q( |4 a. I
},2 t! X5 o9 K- O8 o
{
+ w6 h3 U' C5 J# |. l) G# K3 p$ o .active_low = 0,5 A, r% ~' n9 U( k# m# N6 q3 w
.gpio = DA850_USER_LED1,4 n! h8 B( {$ \, T0 }. M/ e$ f
.name = "user_led1",% Q& i; v7 R' y8 e2 B7 Q
.default_trigger = "default-on",# D+ r' T. l8 B) Y: A" U9 u
},$ H) ^5 Z, t" R/ h4 A" P; l; G
{3 L/ h0 v8 ~6 U/ U' \
.active_low = 0,- t) I% u! `* y9 h% X- {
.gpio = DA850_USER_LED2,9 Q/ e/ ]2 T! o6 U( f
.name = "user_led2",
4 D3 n! P; E" @8 F! A! F* Z .default_trigger = "default-on",5 h( M5 M+ e" S7 `; U7 n! U
},- H7 D1 ^6 x2 e
{
" ?+ A5 ^0 h! e2 I( g .active_low = 0,
w6 u0 G1 Q: w. e7 E4 l .gpio = DA850_USER_LED3,, v2 T# H/ u O3 e4 q# P
.name = "user_led3",$ `! @: a# p9 H1 t7 O3 D
.default_trigger = "default-on",+ {' n5 B# M' v7 p' ?
},
, f o; @* E, Z. N8 O};5 p C; |5 r! M) K( m4 }6 E0 g
. ^0 N# P% X) V; v/ k
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 k: w. a1 `. R) r3 O3 [ .leds = da850_evm_tl_leds,
, a0 g( a) T" D' X) D& Z% g .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( g1 e+ Q% @7 U9 |5 m$ t* ]};1 G7 X+ V5 H O5 }+ \
3 J8 c; t9 H0 b l* }: b: dstatic void led_dev_release(struct device *dev)* B' V$ h/ }: c+ v
{
8 T2 V2 w$ V: q};
2 W: ?$ S$ z6 K5 ^: E$ P: r* V+ k" @. x) |, F
static struct platform_device da850_evm_tl_leds_device = {
( f( E/ F% \/ T; M7 C .name = "leds-gpio",4 e6 B; L9 R. K# Z& k- a+ ^! [
.id = 1,2 ?+ A: v% T% |0 V0 N7 `
.dev = {
4 Q' o0 P7 s; R( s) J4 N# { .platform_data = &da850_evm_tl_leds_pdata,
5 }# b4 Y4 x- w, A7 S! k .release = led_dev_release,
9 I- Y4 ^9 g8 `1 V& `6 G }
1 s- |' l4 L+ g6 K+ c: x};
6 v" [* {% N5 {) F- S" _5 d9 ?( [" ^) z8 P; _) w
static int __init led_platform_init(void)5 p$ R3 @8 B1 b5 `9 X- C, Y/ R
{% U2 o0 T5 l& J* {2 _* f+ p
int ret;: @- q$ U) p, f# _
#if 05 k3 a0 ^4 m; F- Z( r- m- a
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
E, Z& I- z7 x* A4 w if (ret)+ M: l# x4 f6 Y% {6 l! A
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 ]. J2 @ [/ M* s" E, O, s) x4 @ "%d\n", ret);/ Z; ]" H4 B6 }$ O
#endif
9 D0 l& I1 }6 @& W* c7 c8 J* x3 s ret = platform_device_register(&da850_evm_tl_leds_device);8 l, ], [: w; h; a. |
if (ret)" ~. H3 r1 O9 F9 g# C) h
pr_warning("Could not register som GPIO expander LEDS");
" _( v- i$ j) Q! J else w% M( H5 t- d& K
printk(KERN_INFO "LED register sucessful!\n");
2 b1 Y6 V( Y6 ~& [: U6 ~4 N5 {- F1 j' I
return ret;3 W6 T [4 B& E
} ]& q: A; M2 t0 f; [
4 O0 E' E6 g X9 h' ]# Z* J6 o
static void __exit led_platform_exit(void)
. b1 W. i3 Q0 R2 F{/ [- w& z# n- m, Q9 d. @3 ^4 v
platform_device_unregister(&da850_evm_tl_leds_device);6 V( Q* S) Q+ ]8 m$ E: d: X
u4 v3 D' w( K) ^! _% }
printk(KERN_INFO "LED unregister!\n");
. B9 Q3 `9 c/ m0 X: O7 g}0 X( R; ]2 N3 O% @4 Y' V
; z" Y" s- Q' P; a7 C. L
module_init(led_platform_init);
' D' d( I* |( v3 ~module_exit(led_platform_exit);
& @0 o H5 Y, \+ I% ~
5 u, k7 ]/ O9 T1 {MODULE_DESCRIPTION("Led platform driver");3 k7 `6 c& F0 K ^: K6 Q/ z. a6 h
MODULE_AUTHOR("Tronlong"); Q6 x+ ^* v V i( L- ~' w
MODULE_LICENSE("GPL");) v# T& Q% Z/ I4 v8 B
! C9 A- D8 H; }7 y% H
|
|