|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 W4 `4 v- F9 q% K$ p0 o. v4 N6 L
#include <linux/init.h> u: h7 h( ~# Y' _ n2 v
#include <linux/module.h>* e% a/ `3 p: ?1 N0 B
#include <linux/kernel.h>
' q4 X- l$ J* @7 V! Y5 [# Q6 |; {. ?#include <linux/types.h>
7 i$ O0 H( ` ~#include <linux/gpio.h>- C5 b+ T" X9 q+ c \
#include <linux/leds.h>2 H: W. w3 |" z e. z G
#include <linux/platform_device.h>
7 v; y+ r ~7 X* G: ?- D$ _. y' ]4 e1 k
#include <asm/mach-types.h>
- z8 Q' u5 C' \' R8 k#include <asm/mach/arch.h>
: d) w) U6 _6 V4 \$ s5 t" l/ P#include <mach/da8xx.h>! I& ?+ D- @" N
#include <mach/mux.h>1 e: f$ y- f$ e* W- v* [
2 g% @. ]1 y: B! S8 R1 K0 z+ Z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 t" o) e" y5 e$ I#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 M* l9 r' h9 D( D#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, X2 K( G% n- W* ?3 l#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 g7 v' d* [/ n
6 x1 y2 J- u3 `# p8 N) H/ q9 k) ]/* assign the tl som board LED-GPIOs*/
9 v7 E T/ X; a! Cstatic const short da850_evm_tl_user_led_pins[] = {, h% X+ O, `- p+ q1 ~. F
/* These pins are definition at <mach/mux.h> file */% G J8 n6 O1 q/ @
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 p& c, `8 H/ d* j0 @$ Z -1
, E, S* T. x4 z0 Y};
4 F/ O. i0 E* o0 f- }8 q
1 w- B1 N) @; ^8 i* F& O+ L; Ystatic struct gpio_led da850_evm_tl_leds[] = {0 U; n( v" K$ b6 u$ @# y/ Y. z
{; J$ H7 l1 o% A( Q
.active_low = 0,, y7 `" @3 d3 h' k: k
.gpio = DA850_USER_LED0,. c' L$ V1 q' R6 k% E2 V& ?
.name = "user_led0",2 P3 I8 P1 e. T# ]' @3 c/ t
.default_trigger = "default-on",
! W! z( Q6 b x. _ },
) k5 r! _- [" N; q {
' p* X1 @/ @& s% V* f .active_low = 0,
; ^. y4 ^2 M2 c .gpio = DA850_USER_LED1,9 B, V3 w \! I2 j4 I* e. u
.name = "user_led1",' k# t, `5 r: ? ~
.default_trigger = "default-on",6 {1 G) R; K5 |; g: s) o
},& `% K/ ^2 f! f1 J5 t
{
! x8 A& G8 a! o; G2 K3 ^8 u .active_low = 0,
9 g2 m$ t5 X5 |9 \. c. k8 | .gpio = DA850_USER_LED2,
* R/ L7 x( b/ y: B4 s+ g .name = "user_led2",
8 G5 r: q1 C5 {7 D% M0 r .default_trigger = "default-on",# f- ^ v3 \3 E% y) ~2 V5 a
},
9 @) H% ^/ N* l, d( l; Q( g {
' T% J: p9 l, ^- h .active_low = 0,
1 [4 g# \& }" i* k .gpio = DA850_USER_LED3,
8 }; Z$ k! }, N: h/ l .name = "user_led3",
% }9 f$ X- `' V/ q- p .default_trigger = "default-on",
6 v% f: T0 d1 I$ h) | },# T0 D) w9 I7 I: L( k; R! Y
};, i8 Z: w. @, c; k' T
. B, C5 G; w ^& }: Y# p( I- Tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 B' P0 e2 L" N, T2 C% Z6 E$ [ .leds = da850_evm_tl_leds,
0 k6 Q8 I# |; F5 S( ]1 Z. ~, r .num_leds = ARRAY_SIZE(da850_evm_tl_leds),; B1 F+ F$ E; `: l, u
};: s* F+ s! V( O1 W% B
6 h, j6 v3 t0 ~& L* S3 g; _static void led_dev_release(struct device *dev)
, h& ^. {4 e" q. x{
% D* |4 [% ^# J! ]' d2 q};% W/ S( r9 E& c0 R! h d
y3 A5 d. w! istatic struct platform_device da850_evm_tl_leds_device = {
* p/ k5 g' F: | .name = "leds-gpio",
1 `1 }# o% ~/ B" H .id = 1,; I. J" S$ |) s. e, a2 R3 O+ x
.dev = {
* x! p( C7 \- L+ U6 n, R .platform_data = &da850_evm_tl_leds_pdata,# s$ E7 V* a4 z8 z7 Z1 e5 O
.release = led_dev_release,
/ S5 h1 a$ w' d' N4 N }* k" V* V% ?/ g; d+ J* X
};
4 u/ \' R# D. C; X8 A- l8 W U# o; P
static int __init led_platform_init(void): s3 w3 k9 W: Y' } L, r
{
2 V- i; [/ R; \1 e/ ` int ret;- n% s3 |0 i9 a4 K' u% }+ V8 X! ~
#if 0
$ r# Y1 M% Y2 y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ G" ]' Q1 W3 l& A6 g! Y
if (ret): v% W9 a9 k) Q) f2 n6 _
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ j3 [+ x: R( D. b "%d\n", ret);3 _& u/ g9 ^. Q- f ]
#endif" K8 y9 X/ O5 u6 @$ v
ret = platform_device_register(&da850_evm_tl_leds_device);
; \0 S7 L+ Q9 I3 x if (ret)9 }# P% y2 k; C! d# A
pr_warning("Could not register som GPIO expander LEDS");
- F$ s* Q6 h& e else0 @ L3 N$ D1 U3 r3 {7 J$ @( d! }8 a
printk(KERN_INFO "LED register sucessful!\n");/ `( z; K1 N& o" V6 F
8 C0 i0 K$ l$ Q4 s$ M, l$ \ return ret;3 O8 ^6 c4 \1 B4 r( v0 U8 }
}! j- K& Q' o$ I! T
" s& X c# [% h O7 m% \
static void __exit led_platform_exit(void)
3 s {5 u1 `9 \5 K' s( ?{
8 F4 }+ G# J0 @! v) X" g! o platform_device_unregister(&da850_evm_tl_leds_device);; e5 {8 G* L6 ]9 K2 F
/ |- O r# m/ ^ f) Y! x printk(KERN_INFO "LED unregister!\n");
( B) D" {1 j L T' x0 O8 d}
4 t5 C" {( z7 u( F4 D6 D! x8 [) r
module_init(led_platform_init);
5 x+ i, X5 y7 G6 rmodule_exit(led_platform_exit);
; a& C5 o0 E; F" z* P
3 [; P5 U5 V `9 U2 V' RMODULE_DESCRIPTION("Led platform driver");
' f* |: Z- ~ }. E# a4 E& TMODULE_AUTHOR("Tronlong");
& l- h5 ]' q5 X4 hMODULE_LICENSE("GPL");8 @- s$ v# S" a- [* o
. r8 R: z) u g, | I" D. G2 p |
|