|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) }4 _1 T6 [& W" ^/ h' I#include <linux/init.h>8 O/ ?8 b1 A; ]1 l3 i
#include <linux/module.h>% X$ A! z ]" E O8 c9 t. X8 r
#include <linux/kernel.h>) g' `6 p' S& M2 a) H% b. j
#include <linux/types.h>
: j6 ?& f+ }# y9 n8 U#include <linux/gpio.h>
: [8 f& a; f; C# h% b* g, E#include <linux/leds.h>
- H8 h5 Q" \8 ]; t4 g) \#include <linux/platform_device.h>5 ^3 h# F9 [" e! g' j! l4 f- _& Z
" H: h7 B' C/ {5 F5 M' e7 L#include <asm/mach-types.h>% B) c5 L+ X% e& d2 E
#include <asm/mach/arch.h>! W' m5 y2 R7 s$ q; R: e
#include <mach/da8xx.h># k" e4 u5 n+ D0 N8 A \, a
#include <mach/mux.h>- `3 S6 u( @* Z. O) k6 s
! }8 Q- E3 o+ q0 \; M: A- p. f
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" W$ e% Q/ B! v( T
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" c5 W9 c# V: @& |0 i) o) ?2 g
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ g" Q9 H8 y. S* ?0 @' j6 R' z7 U1 U8 ?
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' [7 E2 _+ E C2 n* d. V1 u
3 b) B# {" k" B* Q. `
/* assign the tl som board LED-GPIOs*/
* [# j+ p/ u* E' A0 ustatic const short da850_evm_tl_user_led_pins[] = {
+ I. p/ V! P# {7 D5 b /* These pins are definition at <mach/mux.h> file */
: f" d, t6 r, f2 y DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# C$ s0 y( [8 T* ~
-1- x/ Y& C. L, g: c
};
+ P7 j. x0 s) F' r5 G: r) D+ Z$ P! {
static struct gpio_led da850_evm_tl_leds[] = {6 W3 N' V! F# p4 H: Q- U4 }* l. B3 ~
{! \6 t0 Y: Q& J& i, F' e
.active_low = 0,
0 S2 Z5 `! t% P .gpio = DA850_USER_LED0,
7 ^1 o. N2 f/ G& J& C& I- b .name = "user_led0",8 o; m% k6 s9 H" t
.default_trigger = "default-on",1 H9 w( ?( W# g4 O# g
},/ c% o T$ B/ d
{
* i. R( {& ^2 G .active_low = 0,8 `. ]* s0 P' Y: k
.gpio = DA850_USER_LED1,/ r, U1 I* T$ S/ Z% k
.name = "user_led1",6 }. M, L, `7 Q( f
.default_trigger = "default-on", A- n; c6 Q/ x2 U; B) S
},
/ ~2 f" A6 r- _. L6 w) E. X% J( Y {
- w# w; B7 \( F, C, O* r2 ~- G .active_low = 0,
( [# {& m8 M6 u+ h2 P .gpio = DA850_USER_LED2,8 }8 {" o' B! m/ S E* O0 W9 m
.name = "user_led2",
* K4 O9 `, T4 C0 K; G .default_trigger = "default-on",
0 {. D) l( x# _5 o },
% b% E! H$ C& u4 p$ Q2 D {4 t' @* L: Q1 L9 c6 G& o! T' m) e3 y
.active_low = 0,
4 A' M3 W3 ?, f! k* S .gpio = DA850_USER_LED3,
# v' Y' K4 K7 N8 D .name = "user_led3",
$ G M' i4 c# Q" N- }, ]$ Y .default_trigger = "default-on",( F% F Q5 s+ D. K! Q4 B$ e0 E
},% G1 [- H7 p, q, }! |7 t6 ]
};) g t, ^/ s8 O
- r- P2 q# d' B7 x# vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
C9 t6 @7 W) ?" C3 }- V9 g .leds = da850_evm_tl_leds,
& \: d# I& M2 }& X. s8 Z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& q7 F. |. d/ f8 p1 f
};
4 G3 b6 q! P, P+ G; I
D$ O- c p0 b$ I% cstatic void led_dev_release(struct device *dev)
; Q; R) A/ Y% B' q. m{' x( Q+ R( X2 X5 R$ w
};
/ j& q+ k7 n% [" V, ^+ M/ {, S1 P8 ~' W9 d9 o9 a1 s& C) J
static struct platform_device da850_evm_tl_leds_device = {+ S8 Q5 ?! r4 T5 t( s. X9 o
.name = "leds-gpio",
9 A. t, _# Q: d. R2 C- L( D .id = 1,
) b3 s1 j8 x+ W. c ?5 }) p7 D .dev = {- \) B4 Q$ H- I% P' d
.platform_data = &da850_evm_tl_leds_pdata,9 R- ~5 l7 E; q
.release = led_dev_release, G. G( H$ F/ E) `' C6 A
}
, z( U9 }) {2 h0 h, q: B( h2 j- x8 _0 y};
" t: ^6 J( f0 P: F# U* Q/ h1 e
) D" ^3 U3 C9 t, {! w5 U# mstatic int __init led_platform_init(void)
. R9 a" K N k, p/ d( f{
7 D" y" Z. \( {1 M# A9 B9 H int ret;3 s. j1 x, B k- {: A
#if 0
; C1 u4 X6 v7 ?- r' F ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- x! \0 {7 d; s* L if (ret)1 ?% A9 j3 i9 [6 A
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: P2 V6 v3 M. Z2 X/ Y "%d\n", ret);1 L! s) D7 V- A5 S) r
#endif
* X _! D2 \$ ^ ret = platform_device_register(&da850_evm_tl_leds_device);4 F( Y( [3 c/ S% ~% L
if (ret)$ l5 ^! n2 E% b/ w/ Q% f8 L# I. h
pr_warning("Could not register som GPIO expander LEDS");+ M# R" G7 s0 q' n, [
else
; J5 \0 d1 k. I" ~ printk(KERN_INFO "LED register sucessful!\n");0 A: l% q3 W, E1 M
( i2 Y: c9 s( u$ A' g+ _ return ret;/ Y2 W/ v# s3 n: d1 o+ l* o
}
3 `2 F0 G3 e: d1 {
$ u* K# i: w) p$ z/ U; Fstatic void __exit led_platform_exit(void)
& K* O* l8 j1 b: e$ x$ n, a{4 Y% M/ C. @: U
platform_device_unregister(&da850_evm_tl_leds_device);) t/ Q+ u) z3 Z! `8 {
( r$ \$ F3 E# U! g) U
printk(KERN_INFO "LED unregister!\n");* ]: [5 x8 V" U
}. l7 n+ g/ m5 `
6 s) h4 B" n+ Y
module_init(led_platform_init);
9 T4 ]! p3 e: ?: s' Fmodule_exit(led_platform_exit);
! z; D0 J6 Q9 I9 u1 s
: E: ^! V3 d: z- PMODULE_DESCRIPTION("Led platform driver");
8 \% g0 r' F1 RMODULE_AUTHOR("Tronlong");
' `( K$ e& P' K, t2 w9 }: G9 }MODULE_LICENSE("GPL");
2 o' X6 b) x( c# Z) W6 W. M: w; N* p# p/ d% g1 F; N* O' a
|
|