|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# E/ K, p: C; a
#include <linux/init.h>
* c7 y" {) F& a/ D/ W' m#include <linux/module.h>" }1 w" B4 d2 ]) e6 {% l7 i* B
#include <linux/kernel.h>9 ?1 W5 ?/ r4 t! a4 O% p& _
#include <linux/types.h>
+ {! e1 n: V+ f% l/ V#include <linux/gpio.h>
i4 N7 J1 u" U8 T#include <linux/leds.h>
" w4 K* P7 }- m# W# J1 _ U' }3 ~#include <linux/platform_device.h>( g# k/ Q% M3 q& p' c, q
2 d( d; @0 n# m8 o6 e
#include <asm/mach-types.h>
& C4 A1 P) W# F# r, h1 ^ z#include <asm/mach/arch.h>- R6 ]7 p. n( p
#include <mach/da8xx.h>* k" d. v) o1 D% C- a0 G
#include <mach/mux.h>
7 q+ {' h5 X% m$ z( x( q( P. ^$ B; ?) e# r
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ C& q! J% [ L: V- T6 p: Q( z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( N% ?2 E" e& W; V9 E T0 A1 x2 @1 t#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 l6 N2 E. u6 w( y9 E
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 N. m1 h U' z: x2 S0 b x6 `* {6 u
/* assign the tl som board LED-GPIOs*/3 M4 C J2 `8 J
static const short da850_evm_tl_user_led_pins[] = {
% ^+ B# z9 b/ e# z /* These pins are definition at <mach/mux.h> file */
8 D( s/ t3 s6 k3 L$ \2 Q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- i5 z8 c# h5 i' J: ?& j4 p7 ^; h
-1+ k. c: D0 ~+ m1 Y$ c
};
) P9 d6 \5 i w2 k6 w; [6 H) u9 n3 a; f" k7 I4 J0 r
static struct gpio_led da850_evm_tl_leds[] = {4 i& `* W* M% {
{0 ?' A; `: {1 b& j+ X
.active_low = 0," @' `4 W% }* q3 o; b
.gpio = DA850_USER_LED0,4 r8 `# s$ K6 }5 H( m9 a, H
.name = "user_led0",
% b+ i1 D" }9 r% O% m .default_trigger = "default-on",0 J' U& |2 N8 ^- X9 D. F
},& h) V# `; ^* V" }
{
* W; a1 F9 @6 r& I( t$ k .active_low = 0,
( H0 K' r3 b6 n! W; r; w .gpio = DA850_USER_LED1,0 y U/ h5 S1 L; v' \
.name = "user_led1",
+ K: ~& d0 y w9 z/ Y) S( @& l# g' | .default_trigger = "default-on", x- ~0 b$ B G" k) _ q0 j( H
},; B4 _4 n8 Q' j5 x' B- t
{' I. ?1 c. B8 u; W0 h) a/ i
.active_low = 0,
. g4 q4 O$ z2 w: ` .gpio = DA850_USER_LED2,& x* D0 E J! F/ ?) u: u2 |6 c1 W
.name = "user_led2",6 k! D; R4 J1 _3 @: J' f9 N
.default_trigger = "default-on",
( W7 w2 z7 \# P1 S9 E" ` },( g1 ]- `( s$ C0 r8 c
{
- s ]* e0 h6 w7 U* C .active_low = 0,
8 _* }: g9 X, {6 b- A& j .gpio = DA850_USER_LED3,
* y7 `* P4 i4 B .name = "user_led3",8 ~0 E- U6 @+ w p' @( Z% a) e
.default_trigger = "default-on",
: A5 z' o6 C, |3 ?7 H' h- t8 Q },
2 k' E! @! w. V' r: [* ?& e};+ X/ p k: D4 s8 Y; o4 P( q. C
7 W) G. W& y; _- q' g/ U
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = { y% E K$ M7 _7 o/ E
.leds = da850_evm_tl_leds,
5 O2 F4 I9 Z& Y0 @ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 L) i, e+ H% t0 E: x! Q};3 D7 q: z; U' V* `
" \) l0 p9 X0 cstatic void led_dev_release(struct device *dev)
. V' a7 L' j3 I n1 J9 C{
7 \! [6 R% w5 u7 ]8 d};
/ f+ K5 x- d' f- I. f
7 o$ a k: W! }5 Hstatic struct platform_device da850_evm_tl_leds_device = {
7 u, Z# T( D. N3 L .name = "leds-gpio",) A& K# ~) D/ N- h; s8 G" U
.id = 1,4 n) Q2 x0 k4 O1 k
.dev = {0 j0 B \# E$ L" A( G
.platform_data = &da850_evm_tl_leds_pdata,; v6 f: ]9 b, ]( z1 K' [% f
.release = led_dev_release,! H( v, A7 U6 Y7 F5 \" d3 N, M
}
4 J- g% G. e0 N0 Q) W' k: e2 v' _};
6 l# `% C& v5 l' J& I, P5 ~2 L! k2 Q* d
static int __init led_platform_init(void)
( ]0 i4 [! }- ~$ `; H{, |' ^0 w Y, ~ }1 a1 c1 D
int ret;- q# f1 _1 m& Z$ Q8 R
#if 0
3 F+ u; N7 a4 | n6 g& g4 s4 Z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 n9 P: v5 u; k3 B5 {7 y q if (ret)
2 }* I1 y/ o) J pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; k) q- U% z; P2 A3 _ "%d\n", ret);
7 Y& v- _0 J$ }. U#endif
5 ?1 R. z& U1 i: J ret = platform_device_register(&da850_evm_tl_leds_device);2 d: V; U- d- }2 ?
if (ret)
( f/ S# h6 F8 k, C, D# ?# w pr_warning("Could not register som GPIO expander LEDS");$ W+ X: j8 `8 x4 p2 w8 f' \
else* ^6 a- ]- P+ c5 u4 d2 @
printk(KERN_INFO "LED register sucessful!\n");
M4 N5 N/ T6 K2 O3 o. a1 J7 y5 T% k9 F3 Y* p. d0 t/ p
return ret;
8 R) A) _6 m g1 [8 H}
# R3 y$ h/ [8 b* v
1 Y4 J9 F0 K5 q6 Y0 K9 x" ]static void __exit led_platform_exit(void) P% s) |& Z! S/ `3 Z5 X) J
{/ u4 V) B( | @" U9 X
platform_device_unregister(&da850_evm_tl_leds_device);
1 t" a+ q8 a6 {9 Y _# I; N; L; v3 b7 M) |& A# Z5 {7 s+ F9 i
printk(KERN_INFO "LED unregister!\n");3 J( ~8 h( O6 u! J
}0 q, A1 a& t) |+ j7 o! _) J |
# p! H6 n1 x9 _% Xmodule_init(led_platform_init);. ~7 a4 ]& L6 Q- P% y7 F f
module_exit(led_platform_exit);: ]) k# r9 i$ p! V/ \- V# M
* w0 Z/ O5 p- j! G2 n
MODULE_DESCRIPTION("Led platform driver");5 F# \' _ V7 ]" ~& K, U) A
MODULE_AUTHOR("Tronlong");
# N1 U; _4 p G7 R- {) z% k. J( yMODULE_LICENSE("GPL");6 M h/ E- A' o0 p3 U6 m
, q% ?( t: ]" p* a
|
|