|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* U V5 |; M6 o. b' o$ r#include <linux/init.h>8 t. p( c \+ |1 m, i$ N. w9 f+ l
#include <linux/module.h>
/ a3 q8 l9 r- V9 @6 x' g5 r#include <linux/kernel.h>
% M1 j( ^4 L. C* Y% V#include <linux/types.h>
$ e- @- A5 r6 K8 L+ g% n#include <linux/gpio.h>
) u( l7 ^- \% f#include <linux/leds.h>/ { T& A, G; Z' n. m# S; N( e
#include <linux/platform_device.h>
0 R1 @/ u* x/ I0 m4 W6 ?! m; G
! {, W q( [ [$ B. S7 z( h#include <asm/mach-types.h>
' @' `$ P! K9 K# q9 s#include <asm/mach/arch.h>( S3 V: `! E! J( L/ S( x
#include <mach/da8xx.h>, m% f6 e x4 ~* S3 J( ^* F J
#include <mach/mux.h>
" d1 |3 p/ s( ?$ a6 D" Y E6 @
9 b' p6 L( M& d- E" `+ Z& I#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 U# S4 u' p' ~1 }- r; ^- M
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* z9 h6 `8 P/ m) N) S* U#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 [# I$ R. E: M: [) n#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 c* }1 e# o3 p- y: F7 D4 x/ J
. M- P1 b+ o3 e! t0 U- _* j t/* assign the tl som board LED-GPIOs*/; q: l* j- x1 K9 C
static const short da850_evm_tl_user_led_pins[] = {
$ n' l5 S, l) |9 G }: ~1 \# J /* These pins are definition at <mach/mux.h> file */
! ^& @9 V/ R9 B) B& s DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ W7 v3 r; h; o1 x2 `2 k( B" i -1
1 ?) h& {3 e# ^; m7 S3 C4 u. `};
& L3 F* I: S. p5 s
$ U+ Z5 |% Z( N# ^4 Ustatic struct gpio_led da850_evm_tl_leds[] = {9 `5 B3 c" C0 b1 C- N+ G
{
# U4 `2 ^9 D* z. W- Z% ` .active_low = 0,
9 T, i/ e. }! t; S" P7 i4 H .gpio = DA850_USER_LED0,
& x2 g; ~5 r8 H8 F! y& i .name = "user_led0",
2 p9 w1 ^/ \: I R; y. f; ] .default_trigger = "default-on",9 H2 b2 I8 q) {/ i
},! n6 P4 o- i0 G1 D# x
{# F& G7 _4 ` R9 Q/ S* x, A
.active_low = 0,( }1 k3 Z r* I+ F5 R# h
.gpio = DA850_USER_LED1,
0 z( w2 k* [7 V .name = "user_led1",
3 E( M) r1 R7 F0 n9 F4 ] .default_trigger = "default-on",$ ]7 ?9 w- Z8 u' o
},- Y8 M, `' S" o J" N& A
{
/ B: c' @" X& l) v .active_low = 0,5 y1 Y7 q. v( {- X
.gpio = DA850_USER_LED2,/ k5 B8 X7 E' S9 m' s/ w& b6 g: V
.name = "user_led2",; U2 g& M5 M9 V" x# |
.default_trigger = "default-on",
9 Y- t" y' R( N' y+ ^5 y },2 O) ~8 V1 P8 N' M* ?) S
{! W; }) u7 t" e+ L9 ?/ \9 m
.active_low = 0,: ~: |% d, l( Z4 y1 C- G
.gpio = DA850_USER_LED3,+ e. P$ y; ~+ Q
.name = "user_led3",
; p# `/ h8 F! U( q9 O .default_trigger = "default-on", h5 x& X& K7 r
},
/ O$ a( g \' j! H8 _4 N};( { T4 m$ ^# h, R
" z+ Z, A- K6 w' t/ ]
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" J' X8 C( ~# b6 d, ~
.leds = da850_evm_tl_leds,7 X3 u( O, O5 A& [9 N ?1 y& P
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),' F' _! V4 \# k
};* y: K" \& \% `% H3 E* T. o, {- S
; Q. Z+ _% z- sstatic void led_dev_release(struct device *dev)
7 {& B2 ]/ V% v, G{
4 E4 p3 D0 L! l5 \3 i1 z3 _" Q};
* ^% I# z2 `& V) n: V* p7 e$ g" i! B* A. N. ~4 s' }
static struct platform_device da850_evm_tl_leds_device = {+ ~! r, y9 D0 @4 ~5 m
.name = "leds-gpio",! P- J' r: \7 t6 ?+ Z2 g
.id = 1,& I9 T% e- Y" c; h/ m
.dev = {
( ?; A9 L3 g3 u3 s9 K! f, V .platform_data = &da850_evm_tl_leds_pdata,
! k" X. o# ? L. J .release = led_dev_release,& Q9 u+ d+ p$ b( |) u$ m2 x
}6 l- I0 t" g' Y/ E+ R" `. n6 `% J* ?# X
};; _( ^8 o+ j3 E* j: Y
6 w$ Y8 h% k/ d/ \: g/ J" k
static int __init led_platform_init(void)
5 a Y4 R- ?* h6 }1 q% |2 k{9 |6 y# L7 X$ W2 P- m6 w
int ret;
7 C1 F# F/ p! R* x4 |#if 0; h T6 s/ E X0 o# X6 r5 R% w
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ O- Z% F9 ?+ S9 ~% T. N if (ret)6 ]" k% K# Y4 p, |$ I J3 @
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 b* y! r! v1 [0 U3 J "%d\n", ret);
; E& h% r/ k, [: X5 s9 n/ P$ [+ V#endif
# n5 Z; s' J, E ret = platform_device_register(&da850_evm_tl_leds_device);: p/ [; ^+ c, Q8 @2 \' F/ E
if (ret)
4 H3 z5 H2 {* g( L+ V# Y, z pr_warning("Could not register som GPIO expander LEDS");9 R: t, e p. O. W
else
1 o! Z- o! c* J, N, Q* W( G- c printk(KERN_INFO "LED register sucessful!\n");* [4 D4 q; Y+ L* `4 S9 K
/ d/ A1 G/ |7 c: p return ret;3 @1 R, E5 m2 @' E' {% F/ e
}
7 ~! Y* _' J; x$ F. j R, Z- H: t& k% x' L1 g: L
static void __exit led_platform_exit(void)& v( [* A, h* A" d# x
{- s& D. d* ` O k$ u
platform_device_unregister(&da850_evm_tl_leds_device);2 @7 G& s' B1 u
4 W5 V" [5 f3 L printk(KERN_INFO "LED unregister!\n");
I" { H6 B0 Z5 c}
8 L! H b( Q1 _1 k9 h, S( y9 T2 {0 Y, N. ?3 N7 ^1 d
module_init(led_platform_init);- z0 ^4 R5 s( \. v
module_exit(led_platform_exit);/ d6 y7 | o2 {% I3 ~
1 P" T3 R5 F& t. A5 ]5 S; Y+ \/ {MODULE_DESCRIPTION("Led platform driver");# c! x( w- j5 Z0 @8 S
MODULE_AUTHOR("Tronlong");
6 U, J R5 W0 V! q% iMODULE_LICENSE("GPL");
$ a3 d+ X4 B# s2 c0 v! R( d0 @- j8 n2 }8 i
|
|