|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 J+ Z1 I5 m- p$ m' m4 R* Z9 I
#include <linux/init.h>
9 J p1 C6 O) Z) |4 S9 p2 l. y' i1 O#include <linux/module.h>
& p/ h. B3 i8 h" s( g8 Q#include <linux/kernel.h>
# _7 a9 S& W% {& U, ]#include <linux/types.h>
- k# @% C' |3 s; b: J# n#include <linux/gpio.h>
* k& H# i f2 z! T# D* ^#include <linux/leds.h>3 H. h: h& e7 @
#include <linux/platform_device.h># m3 \4 u% Q6 p8 q2 i, Y x+ ~1 Y
& a8 q3 o$ n, m#include <asm/mach-types.h>
9 j" K( |- z; F#include <asm/mach/arch.h>
$ H' R) R3 q0 B- r, F4 ?#include <mach/da8xx.h>
! N% S0 j3 V/ O& N! n& A#include <mach/mux.h>! Z. }- V' G$ G+ {8 H S
$ j c3 N: U `#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 i6 f: s' a. U( ~ n I#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 N. n+ k; L3 I: w; e#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- C5 y' P! v* U" D#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 l% e2 g( y: P# K$ V3 Q
C4 U; ?8 u" I$ l5 N/* assign the tl som board LED-GPIOs*/$ S" D# K% E. S3 Y2 k8 N
static const short da850_evm_tl_user_led_pins[] = {$ v+ M/ U/ w+ b+ g
/* These pins are definition at <mach/mux.h> file */
+ l" f3 {9 }+ ]1 w# y/ S DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 l) N- ^$ @$ X! q y; q -13 g1 k- a( v" i1 M l* T# s
};+ T1 x+ G0 }( J1 L k4 X3 b' N
8 D; F* J4 ?/ ]& T- G% Q9 Q9 nstatic struct gpio_led da850_evm_tl_leds[] = {
* { |4 X) H I) Q {
7 S3 w, e# W# E- }1 k- k* D# z .active_low = 0,# T% g3 D& B& X$ D& t- {6 _7 `7 H4 \0 A5 `
.gpio = DA850_USER_LED0,
9 g+ n3 L0 c/ T# q- }5 l. n" x. O .name = "user_led0",
5 Q5 U- M3 |; z/ U* W .default_trigger = "default-on",7 z4 F$ U( h( ?0 `
},8 O4 f9 ~* ]* C1 p- w: R* J! d2 K
{
% ^+ o/ v8 q. s/ K* p .active_low = 0,
1 l; R% v6 @7 u' U4 ? .gpio = DA850_USER_LED1,! @1 i% r/ b; G: }5 x7 {2 }. A
.name = "user_led1",0 R5 S) l4 { j" o
.default_trigger = "default-on",
$ G# w. Q& ]$ G },
0 Y7 D( G" |/ z4 i$ D8 } {
* T$ _" |8 |' _ K- f .active_low = 0,
5 E' F( C$ U$ a' V .gpio = DA850_USER_LED2,/ Q2 G! a1 u9 e! a9 C
.name = "user_led2",
* T8 f7 V: [1 @1 d3 m' E2 H, i4 r .default_trigger = "default-on",& y; _9 k& }; h+ u5 X/ C
},7 \, t+ [ H9 ]: b7 Z2 G7 Y ~
{
: L# t8 ]) u( F* \% z4 N; `' Z .active_low = 0,
+ i) o; i7 H2 L M- v3 {) C! l/ J .gpio = DA850_USER_LED3,; T+ L- R* v4 Y0 x5 m! o
.name = "user_led3",& w9 v D! ? t/ X$ o6 e9 I' B4 X
.default_trigger = "default-on",
- J4 d9 o7 w* M+ z0 n' \ },0 }: H: ~7 B) h# E
};
6 j# B. k2 T. ?: Z2 A' ?* m& W( {2 o* j( v" f, ~! P0 b- \2 J+ q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ K3 F6 p; n) I/ s) W$ ]+ C: O1 a
.leds = da850_evm_tl_leds,- W/ P; f: P- D* |2 C! x2 [
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),: d5 M# w1 H9 S6 F5 ?4 U" x$ R: Z7 Z7 O$ a
};% s4 J2 p, a4 |) R1 Z, B9 F
, J0 u0 W# f- j9 cstatic void led_dev_release(struct device *dev)
( D6 g; [2 |+ E5 E: d: A{; X1 w5 K* J; v
};
: o: H! r+ g& G: r, l" [+ V1 Y* o8 P! ~
static struct platform_device da850_evm_tl_leds_device = {3 G; L3 j. y5 ~) q# i2 |
.name = "leds-gpio",. @) E2 ?1 m" E6 r- A
.id = 1,
1 G. B! k9 k/ a# P E .dev = {5 m4 X, a0 g: ^; t7 Z- E/ E# L
.platform_data = &da850_evm_tl_leds_pdata,# A3 M- ?6 b) W# V% _( {/ M8 }
.release = led_dev_release,
# W- B) z1 b0 G; B }0 `- ~$ {4 C% d( q6 k
};
' T" Z/ v6 K1 m6 i( @8 @3 ^4 e
; ?: ^8 H, i- q3 N; Kstatic int __init led_platform_init(void)) s) Z& b* x7 \1 y" y. a$ O
{
$ q4 N' K6 @9 w5 F/ @/ K int ret;% J7 z- K6 e4 B: i1 A" \7 W
#if 0
' O. A. I+ `: i ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 e- P* g, l3 s, m if (ret)
; W* G+ c% a9 j6 c t! g5 ~ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 l% ~, U. r2 L6 \, \6 [ "%d\n", ret);8 a6 |+ O% {4 w$ E5 O: z
#endif; }5 w% T+ Y+ S0 t) @
ret = platform_device_register(&da850_evm_tl_leds_device);
/ [* r2 W1 F' d3 D" H* b if (ret). i# V3 v/ n( B' }# n f4 e" L" P
pr_warning("Could not register som GPIO expander LEDS");
) t& O/ b+ o5 w0 e' | J9 P else
! i. q7 Q1 d2 Z printk(KERN_INFO "LED register sucessful!\n");8 a3 S% [' }; J$ [- M5 N2 G# ?9 o
: l( l4 E% y- h9 [. u return ret;
0 p# A: A% D; ?+ @5 k* r) ]1 l, t}. I- B/ L }8 ~. `4 o
% D* X( R N; j0 u
static void __exit led_platform_exit(void)
W9 l* |/ u) M3 U{& X1 D1 b2 s& r- T
platform_device_unregister(&da850_evm_tl_leds_device);& T% R5 e% O; _% s
! ]6 D) t* {4 f: ~& T. K printk(KERN_INFO "LED unregister!\n");! ~* i8 N, ]1 ^' O9 }1 l3 \
}- Q8 X! I! ]' v8 B
/ S) I. r; n. Y. g% |
module_init(led_platform_init);6 y* x7 @) |. Z
module_exit(led_platform_exit);3 k+ P7 r2 b$ ?( x7 u
+ c' M9 f" }: j4 o& Y% U6 kMODULE_DESCRIPTION("Led platform driver");2 K6 @. k: @7 o' c, v; a5 m
MODULE_AUTHOR("Tronlong");
! P" N( X, Z2 J* @" T$ r3 IMODULE_LICENSE("GPL");
7 D: k8 N" ?7 [$ B3 f! t9 o3 Q; s) l2 ^1 y9 t" i9 h) R7 w
|
|