|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' w; U( \& c1 X4 W
#include <linux/init.h>
8 _/ c2 E6 e& P9 Z$ v4 V D#include <linux/module.h>
1 V) G: B% d2 h; V' ~. I#include <linux/kernel.h>
3 G& |* Q+ W0 P( x#include <linux/types.h># Q) `. y U7 l+ C" J$ l
#include <linux/gpio.h>9 l5 B" T4 n% q% \* C
#include <linux/leds.h>
( s! ^% e* i- \#include <linux/platform_device.h>/ i i9 H# k# e7 U
]( s: j3 @; S* A% g2 |) ~#include <asm/mach-types.h>4 ]" }3 j1 j" L. o3 W
#include <asm/mach/arch.h>
6 X8 P3 X$ n. Q- m. z) G0 g#include <mach/da8xx.h>
9 T' \ ?4 O+ N" L; |) s#include <mach/mux.h>: J4 I4 L# R9 l3 q4 r3 J2 s8 y$ f
; \, E% |" x' q; u1 @, f9 s#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 Q4 @! G; Y4 ~, m& D#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( l/ g% k5 W" q$ Y9 _, ^#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) x4 R; O2 G# }6 d! l8 H# z& G4 h
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* H% L( W6 Q0 u3 ^
7 I+ |3 e" A5 D4 S* M2 T8 g8 x/* assign the tl som board LED-GPIOs*/
$ b2 Z' W/ R L0 h' f& z; sstatic const short da850_evm_tl_user_led_pins[] = {, ?1 T2 @& D$ q+ F0 U
/* These pins are definition at <mach/mux.h> file */
" o/ g3 M+ _, M( s: ~* t' ^, U1 f* c DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 I7 f7 A! ^/ ]# q$ M' H -1
2 B/ [0 w. Z! o5 s& l! F6 i0 t};+ K$ [9 ?1 h8 g
3 E# N: H, X: |
static struct gpio_led da850_evm_tl_leds[] = {6 R% R7 H$ ]# i) B2 u; W
{% P5 \8 Z% v( r9 }, L! X
.active_low = 0,' s, d4 w! l ?4 \0 F: W7 a
.gpio = DA850_USER_LED0,
7 s! s9 u' ~# g .name = "user_led0",
! V3 \, H" K# Q* I .default_trigger = "default-on",
9 S# A3 t; B8 V- R& N( L0 m6 P },7 o* t4 t: B3 y0 Y3 Y# S A$ j9 a
{# S- f; k! z; P8 O" k9 v
.active_low = 0,
% [: n5 U" Q z2 x1 u3 }! t .gpio = DA850_USER_LED1,* L4 F" b! t9 Z$ R6 q3 O
.name = "user_led1",0 Q f& Y+ j& |3 I; b$ v
.default_trigger = "default-on"," D% I& I8 o3 @
},+ ?9 K' g6 ?7 r0 A. i( u/ q
{
5 o( N3 g6 I- w$ q! j6 \ .active_low = 0,1 G. x1 d1 A3 E
.gpio = DA850_USER_LED2,
* Y; S$ M5 U+ k1 k3 ]) n .name = "user_led2"," y u5 \. V4 }4 s
.default_trigger = "default-on",
) |1 j1 D8 V+ n% V { },
$ A) ?" o6 U# `% ~) G {
0 W" M3 n/ Z/ u+ n1 x8 d .active_low = 0,$ Y+ Y! V, H5 v0 g4 [
.gpio = DA850_USER_LED3,) @+ l5 G1 Z; g# D3 s) U
.name = "user_led3",$ {& }! ~# a0 G0 N3 q! V) A
.default_trigger = "default-on",
$ S( B2 }( k6 k7 j1 D. s },# i2 i1 N0 m2 Q4 X: O; G0 h$ c
};, t# D& G# H+ B8 Y' B7 O" I4 F& f2 n
" e) h q9 e1 g1 Cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% I! S( A9 ~" ]# F, Y9 r .leds = da850_evm_tl_leds,
`& n* e$ s3 k, d4 Q2 P8 z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; ?: H ?$ t) p% d2 D/ F9 ]' ^};# Q- ~. h9 D+ y0 Y6 V
- }3 r6 N" v6 X4 g Z5 Z9 K
static void led_dev_release(struct device *dev)2 k; h ~& \" R$ Z2 t1 b, r6 w
{
/ r0 h# C( M1 i! O$ u7 E};
; {* m. T0 M+ Y/ i. ^
/ B" z, U2 z- R3 i- P& Ustatic struct platform_device da850_evm_tl_leds_device = {
! a( w' ]$ W( @ .name = "leds-gpio",6 P% S4 {9 J4 _% S7 ]3 j F
.id = 1,' A/ X6 q. ~0 @
.dev = {
* z; W7 E+ w2 @" p' o .platform_data = &da850_evm_tl_leds_pdata,, j& t$ o$ o5 ]" Y$ Y9 ^
.release = led_dev_release, y# R" t) K" r( @) P M) R
}: Y! v- K& m( v$ l3 E& I3 k
};) y, `( O0 p0 |: K
' v5 ?; G2 `- N% I; i/ V5 p& istatic int __init led_platform_init(void)
4 m$ U( j; s" Q{
- R9 |( G& L+ X! \3 o int ret;/ K' J8 p* I# a1 t$ r
#if 0
9 W0 r, t5 y/ \$ F$ W ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ t# a( v3 P3 x1 h, ?; q if (ret)3 V" I* K4 ^& [- M$ r
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 g! ?/ b% }3 q; `" h" h3 O+ i- K3 o "%d\n", ret);
8 X# M. T& s% ?2 @+ }8 s#endif) F/ S% e9 k$ w. b: m* k3 i0 M
ret = platform_device_register(&da850_evm_tl_leds_device);
% ? y6 o3 W { l9 g2 F5 F" [7 u if (ret)2 P1 G4 @9 S6 y+ l0 h1 N s5 o
pr_warning("Could not register som GPIO expander LEDS");3 }' L5 A( A* Z5 k6 K9 n0 b) z
else/ s5 A( q3 s4 u1 |2 t. G
printk(KERN_INFO "LED register sucessful!\n");
0 p! g, c( `) l/ E; L9 n8 p+ c
5 C+ y! H+ F. S7 y* t( X0 B5 \ return ret;4 I% P. [# i- E0 ?: o# U: S
}/ R2 z$ M$ k* g& c! w2 _5 a" B
% S; H5 Q0 X/ i' d8 n) rstatic void __exit led_platform_exit(void)
+ p3 `0 @. b6 E$ [( v9 S0 P5 |3 S{ b0 d) e' L! \
platform_device_unregister(&da850_evm_tl_leds_device);! c F& R! S" `! z0 g. z/ x& H! ^ K
4 ^! w. J% Y, K" i4 W printk(KERN_INFO "LED unregister!\n");
6 z4 j- x+ a t; O' R}8 U1 _3 Y1 A; i& p1 g/ |
8 U% F; J! V* n( `, u* t8 R5 F
module_init(led_platform_init);
1 w- C j& q _. K, t, \) M: Fmodule_exit(led_platform_exit);
5 b! @8 s8 N. Z3 k% q" {3 A3 ?7 `' ^& c( x) g# o
MODULE_DESCRIPTION("Led platform driver");
9 R- C3 {. V# g6 ^MODULE_AUTHOR("Tronlong");
, d t' I4 D) D; U: U! vMODULE_LICENSE("GPL");
4 [- i. L& g& F* B
& T9 {% O) m; t7 {0 G0 C: M |
|