|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. h9 Q$ [, O4 o" g. D" h, ^8 ~#include <linux/init.h>
7 o' E* D U; F+ D, J/ x#include <linux/module.h>
' k1 }( N1 s8 K* `, l/ B#include <linux/kernel.h>
5 N$ K( M0 U! b3 |#include <linux/types.h>" N$ K1 L0 ^& j; @$ t! ]% i
#include <linux/gpio.h>4 Z' A; `* g9 C3 a' ^ R2 \
#include <linux/leds.h>$ r$ j! Q6 Y$ ^7 V3 [3 v7 y# \
#include <linux/platform_device.h>
3 \/ t' {+ U& L$ ?) E9 W$ x5 c; y3 t; G% w0 O* ~7 s
#include <asm/mach-types.h>/ G: h0 Y1 [( Q6 r
#include <asm/mach/arch.h>
d6 A5 Q( E# U# ~$ H1 I' D7 w#include <mach/da8xx.h>: f% a, r/ K, U$ E4 `
#include <mach/mux.h>9 H8 b3 G# j" M" D6 E
) k0 J! ^8 {* O6 b2 p9 q6 X
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ M$ W5 w2 T% K. Q3 c#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) R4 b$ l+ D' ?: d
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# a9 ?, [+ y: A8 C$ o) @#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( h1 }; _% d: _( V" s2 k* _
9 s. w6 j5 E: s4 g9 R/* assign the tl som board LED-GPIOs*/2 e, c2 n; w5 q. V' |
static const short da850_evm_tl_user_led_pins[] = {
, ?( C$ b0 R+ F0 ^ /* These pins are definition at <mach/mux.h> file */
6 K$ @; I6 l+ @; Q0 L DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& `: l% W5 y6 q9 A: K: d -1
0 k+ s i2 |! J" w' `};: E/ k3 p' T) s4 n
S( n6 H/ z& J$ x9 A' Hstatic struct gpio_led da850_evm_tl_leds[] = {
) v) }# v# U1 B/ a" N7 Z {
" D# p/ w n: @: Y, Y! k) q# A .active_low = 0,
' e4 p! ?( J X3 q .gpio = DA850_USER_LED0,
1 Q3 q0 g) V9 @1 l0 p) q .name = "user_led0",
& n6 P, Z0 }0 k: |) x- t .default_trigger = "default-on",
0 j& u1 `7 x) \" Q' ]( H0 Z7 t* z },3 }" T4 Z. y; w5 F: a
{& k8 W# |" s) t+ ^
.active_low = 0,
) _0 L) x6 c' N% b$ @5 ~( e' S' e2 J .gpio = DA850_USER_LED1,3 N7 H8 B" E. M" d5 y/ V
.name = "user_led1",
& S1 _& d( H/ u/ n .default_trigger = "default-on",( F0 B1 w6 |: Z1 B
},) B$ t2 ]! Y- `6 u
{
* g. e* p7 ?5 V' I6 e' [ .active_low = 0,- h; d- n+ q) f; j
.gpio = DA850_USER_LED2,7 H, o4 {6 @& V/ N% o
.name = "user_led2",
0 V) w* Q' {; H3 l4 F .default_trigger = "default-on",
; k4 f4 M- m0 s( p* M },8 d" g! }1 q& ~4 q |+ U6 a2 ^( q
{& G* b# _8 I6 z( f9 E) {) h
.active_low = 0, H: m) Z0 h/ I: G) U) {
.gpio = DA850_USER_LED3,* J7 f1 H1 x& u; d6 g
.name = "user_led3",
3 |1 z! w( y' w8 E F .default_trigger = "default-on",
8 p: E) ]8 P" w7 x, f/ H },
; X7 H' J R, s& T$ a3 A};3 Y6 f7 l$ p3 y* T9 d
& K6 a2 D ~+ G" E' \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 S- Z6 z" N7 ] .leds = da850_evm_tl_leds,6 f/ | l: z6 u- A. S. m
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ _! u" L- D& m9 k& `};
) r, B2 g3 L: ^. T: _+ U. z2 ^
/ o3 ^ i1 T3 e" U/ Lstatic void led_dev_release(struct device *dev) Y/ K% j" D8 ] R+ w
{7 x$ r6 h: v/ R' g
};3 }2 w' @6 A8 V4 J! P7 n$ y4 y
6 [2 S9 f, \. Z4 ]4 B5 |, ^1 n$ g
static struct platform_device da850_evm_tl_leds_device = {
% n6 x r/ P0 j( ?! F1 J" w1 I .name = "leds-gpio",0 y- w) M' S% k w6 |
.id = 1,# d7 Z- |/ E2 T9 Q3 h5 G
.dev = {
2 b! C: E' C+ n8 E2 n) K .platform_data = &da850_evm_tl_leds_pdata,
2 N) R; Z. `! V) \ .release = led_dev_release,
. v7 z4 c: K: h3 o. Q }1 T. H! G' f8 D0 Q
};
9 o0 K, ]! a1 `- v% M3 @1 e& B* t3 ]# s' o: ?
static int __init led_platform_init(void)
% ~8 N- i8 x! X1 J& P" x/ [{3 y+ [$ i- @( q' f
int ret;
* Q u) U6 c* W3 D; r9 d; c#if 02 ?0 n" D1 g# F3 `
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( t3 L" N% D( z
if (ret)
) B7 ~2 a* ~$ B, y, w) ]+ } pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 \/ Q* Z! D, K. t1 T( Z9 Q "%d\n", ret);9 V% d! m; A, p" }, K0 ~
#endif
/ s6 S0 _' [4 j! d8 c ret = platform_device_register(&da850_evm_tl_leds_device);, L; e7 \, |% h# }" s
if (ret)
' B* j, ^! b- Z' K) ~, Y( l pr_warning("Could not register som GPIO expander LEDS");# Y9 p1 E" }# V/ h: i5 l
else& j* o" [) Q, I! w7 ?' ?
printk(KERN_INFO "LED register sucessful!\n");
& S/ F0 U R/ y$ c% ?+ r
9 ~5 t! `2 G/ r* y4 Y return ret;: Z2 e2 x$ X C
}
8 t* U( D* W* D' f% n1 i2 i" L" U% X. N" `
static void __exit led_platform_exit(void)
6 e- y. T' W+ M" S" o{; z% H' W5 L7 G6 S
platform_device_unregister(&da850_evm_tl_leds_device);
+ N2 Q% A6 D' w3 H! C! V/ t7 U+ p1 w d+ f
printk(KERN_INFO "LED unregister!\n");: O. F l$ B+ o+ l5 c" L9 P3 u3 ^
}' ?4 M8 H. ~ @
7 |/ Y4 s2 F8 Cmodule_init(led_platform_init);1 R& B- W3 [: h) E0 c O
module_exit(led_platform_exit);! a$ c! l$ t9 m$ V1 G0 c* y" ~7 N
& X4 g& f3 x1 k7 j8 N7 C/ A
MODULE_DESCRIPTION("Led platform driver");
1 R# e* |: h$ W A$ e; Q5 b, e9 KMODULE_AUTHOR("Tronlong");
0 q/ g, ^0 _" {- M$ zMODULE_LICENSE("GPL");
& j' a* a8 h: h$ j# b
4 i; H# K9 p2 Y$ Q |
|