|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 o; T4 k7 f8 p' @- l, S
#include <linux/init.h>- [% m9 L% @ z7 H
#include <linux/module.h>
; t$ X3 U. ^, g! P: [- E J#include <linux/kernel.h>
% M- W; V& _# \: e! }( B; D" N#include <linux/types.h>
0 i+ G' k: a) S; B% G0 v$ X#include <linux/gpio.h>4 T/ c( a- j1 R5 B* b, W @
#include <linux/leds.h>9 z% I0 {: m" G3 A; t
#include <linux/platform_device.h>
7 D: x8 d/ h3 [/ S! v9 Y2 [ |
7 }: X# ]1 s8 _: E m#include <asm/mach-types.h>
+ e. a& M( K* O0 e#include <asm/mach/arch.h>- F6 h3 _: k; K% h1 X
#include <mach/da8xx.h>
' f; S2 c: |$ m; ]$ `' H#include <mach/mux.h>4 |# E/ X) R/ X3 C
9 R; `0 V3 |8 W& D/ }$ [#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! r- C7 r; w8 B$ D; e, V$ {#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 {; [, h% c. P4 ~$ o7 ]
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" D6 j; ~& d$ C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 n" ?: U" L: u* {2 X) z# L6 ~* O
! N2 i. G% R* K9 X1 l
/* assign the tl som board LED-GPIOs*/6 [3 k6 L: _+ F$ F: M6 g5 x4 |
static const short da850_evm_tl_user_led_pins[] = {% _, u" [2 P. G$ f* Y& {
/* These pins are definition at <mach/mux.h> file */0 U5 V8 C2 _4 o' i
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 W y8 ~% {! K4 t. V5 a& N -1
( V, n, s& K5 |+ B) U};4 V, w. c' X* H- }% E
- M4 Z1 s5 t" gstatic struct gpio_led da850_evm_tl_leds[] = {
# a5 Q3 x7 I2 ?# _6 m- z# q5 J( }* G {1 ?- I; j) `- ]+ f' `
.active_low = 0,
/ H/ n3 Y; X" B4 Z .gpio = DA850_USER_LED0,
: T& N, ~2 v, i) t @, d% r .name = "user_led0", O Z8 Q7 h9 h5 O* n4 x
.default_trigger = "default-on",# Y: g, c/ [- l" Q* s) E
},5 h6 d$ J) R- e+ \3 U, s
{
2 n- ]( { H; b4 _3 f/ e+ f .active_low = 0,5 D) a% B7 }+ Y7 r7 E
.gpio = DA850_USER_LED1,1 ]/ b$ Q, ^ w$ [, i1 U, B! X$ I
.name = "user_led1",
6 @* [" Y2 j. v3 l: p& ~ .default_trigger = "default-on",$ W* \& m7 O1 l# s
},7 E- d8 H' {0 y! S" \) K* N/ S! U) M
{
% D9 V9 g$ I" O5 W- c: O .active_low = 0,7 U6 ^' j9 T' Y* ? W9 D/ D
.gpio = DA850_USER_LED2,1 o9 v+ `+ f4 [; _8 g
.name = "user_led2", R/ K7 I: ~; ?9 }: b8 D4 e
.default_trigger = "default-on",6 {: o n$ Q+ P, l9 l9 m. x
},& H& o! t3 ]1 ], Y& S! ^
{8 N& p- L! L) _; E6 \
.active_low = 0,* |% e! i+ k Q' n; Q E, |
.gpio = DA850_USER_LED3,
3 v1 i. x ^. h& X2 Y, G. n/ I .name = "user_led3",4 x; D1 M+ c( L$ ~* t; q( d
.default_trigger = "default-on",
* ]/ x% m s9 n `7 \. N2 J, u5 C2 D },
2 I0 Q3 z6 _0 j) l};
) ]! b% {' _: |+ S! S! C, I, |, a
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! n3 `. ~+ Z6 o- ^
.leds = da850_evm_tl_leds, ?( C+ G+ X1 Y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ m- m- ~' P, R h; I y
};
2 s! B/ D4 r p& f/ [+ N; G0 U9 W1 ]$ M2 M/ O& Q
static void led_dev_release(struct device *dev); j; G& W+ k# X: H: W
{
" D5 E8 j4 O3 \7 I9 M};, M& _$ w/ V! Q( M, M
- g4 @2 ?$ H* h8 d: e$ |: a* }static struct platform_device da850_evm_tl_leds_device = {
) |) o9 w! C8 @) [( X' j .name = "leds-gpio",6 o' X% r* |; g' W1 X8 i
.id = 1,
, a3 ?* f9 Z/ ~- c9 Q7 |1 e .dev = {
/ _8 P- L! P0 F0 K# p: l# S9 ^ .platform_data = &da850_evm_tl_leds_pdata,+ ~, Z7 P& U" j" S1 v/ m8 e0 v
.release = led_dev_release,
# |; x8 Z( A5 U& L4 s$ w }
2 D9 ^8 S c+ \0 S" z, u- X3 ~) Y" H};
& }, r5 @& t5 T6 Q# ?8 {7 u
6 |/ k# G! K7 Q3 H9 L; ~% E0 Ostatic int __init led_platform_init(void)
4 \2 V3 e) K$ S1 b% K; Z$ |{6 M% H- M$ j- A
int ret;
; a4 x, [5 d/ W6 y5 z1 \#if 0. E3 {; w0 {5 E; o! E
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( ^5 k, x! K) a% H7 u% Q if (ret)
+ j& k: G" ^6 W pr_warning("da850_evm_tl_leds_init : User LED mux failed :". f/ _* j/ |) v6 b' K, T8 i, Q
"%d\n", ret);
& @ z1 g' m R0 @) k. F#endif/ i1 Y: x) M' }
ret = platform_device_register(&da850_evm_tl_leds_device);9 Z5 A! B7 t. |* S$ i, q' y
if (ret)/ e" O# O: y! H4 s# M$ c
pr_warning("Could not register som GPIO expander LEDS");) k) S H* p1 T& k
else
8 E p. T' J* X; K# d. Q- L printk(KERN_INFO "LED register sucessful!\n");
, b/ \ {4 L: j+ l( }/ I& @5 O" N$ F) T& Y
return ret;
# ~7 _9 {: g, l1 n}% y5 S6 E9 s, O4 Y2 w$ @" _
- i* Y, ~9 X% L D8 [
static void __exit led_platform_exit(void)
8 E+ `+ F' i5 f( W% }0 I{
0 w. l" p' w" _" \# \1 k7 H platform_device_unregister(&da850_evm_tl_leds_device);. Y1 V# h; r2 g
- Z5 L: i. y6 D. D' I% v printk(KERN_INFO "LED unregister!\n");
9 I, ?2 d' ]* d H}4 t9 A. T8 w9 \8 M! P
1 A# T5 [9 }& h- g$ M. f( L7 ?
module_init(led_platform_init);
6 B% V3 E$ U. f6 i Umodule_exit(led_platform_exit);
+ L, [% _: \) H) B/ V% L7 Z8 ~/ Q
MODULE_DESCRIPTION("Led platform driver");
# a* y) d) e) B5 |2 D- dMODULE_AUTHOR("Tronlong");9 W5 C' H# X' [
MODULE_LICENSE("GPL");! v* w( [) W$ }/ S, o, p- K! b* i
+ K8 E6 A* d& E* ? |
|