|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 U4 I/ W( z* ?. j) t& ^
#include <linux/init.h>" w: h3 f9 t* R5 S! p/ y7 H
#include <linux/module.h>
8 j: H+ {4 w# E. F4 |#include <linux/kernel.h>$ Z9 ^! H- {# B0 z, I
#include <linux/types.h>/ _: Z9 Z5 B( h8 [2 {; f" f
#include <linux/gpio.h>& Z) I' D8 b2 p/ z- P- ]
#include <linux/leds.h>
& G: D# W( j! ?% k/ X7 d#include <linux/platform_device.h>; ^, [ G; K/ ~5 D1 E/ r
5 @4 O2 \# n$ Q# } j
#include <asm/mach-types.h>
" K ^( P& y+ x6 z- ?" H, N#include <asm/mach/arch.h>
1 u4 |( \! V" }: s4 i0 K3 a#include <mach/da8xx.h>
4 i9 d) ]2 o) Q7 p, ~+ e/ z1 I* x#include <mach/mux.h> q) m& u1 ^# A: V \1 U3 }+ m' _
+ I$ ]) L7 e7 r! ^# ^ @
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 h" u- J* I) h8 g2 `7 C
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: A4 C a4 S# u: A4 @#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ t, i- h, ~4 S- P" ]9 ~+ ]7 N5 I
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# W/ `# W! ?" e' m
+ u, }2 K$ _. g4 N; _3 ?
/* assign the tl som board LED-GPIOs*/
" x9 M. |. i+ M" _static const short da850_evm_tl_user_led_pins[] = {
2 {& i9 k2 M) P) z /* These pins are definition at <mach/mux.h> file */$ F' k2 ^7 U2 q; t: V* N
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," X% y% J, D& x* h( y! E
-1$ {/ B3 j# K/ l) L) n% z. G- U; J' d
};
2 O# e( }/ \% x& R
% A0 J: B. \# W) y7 qstatic struct gpio_led da850_evm_tl_leds[] = {1 q# f# |. H- ^1 o
{
/ m6 u. L$ k1 D9 d/ S% _" H5 x .active_low = 0,( z! i+ D' F1 w9 m. R
.gpio = DA850_USER_LED0,
5 K: P7 w- s# k: X* r .name = "user_led0",
* d) }. r+ Q! o0 M0 k .default_trigger = "default-on",
% ]8 q( H* a& ^; N },* @1 b. }& ~0 ]7 L2 {
{
3 q0 K. [7 h" [. q& l .active_low = 0,
1 c" _7 M- r1 y% n' Y .gpio = DA850_USER_LED1,
6 S. C, t; g6 | .name = "user_led1",
2 i3 S' m4 m# R' H .default_trigger = "default-on",! Z; S( M5 x1 H, l: {
},9 g/ X' n- T" t, s' ^# B4 k( o* ^" G
{
7 T0 R' x% r7 D# `( g4 S .active_low = 0,
& @& m9 l4 e- ^% h" ^- x" p l .gpio = DA850_USER_LED2,
8 _" Z9 r; U- H- U: S+ R .name = "user_led2",
* {; F0 k- q m6 b* ^/ R! Q2 W .default_trigger = "default-on",) `7 r! U- Z9 z# c2 E( S
},
6 ^$ V4 T9 Q+ I9 X, q; Z* s {
3 ?& s/ o9 u9 } M" s3 b .active_low = 0,; `7 i' y c/ M3 @4 m1 w
.gpio = DA850_USER_LED3,' [ q, i+ M1 N+ q( ~7 C7 O) Y8 t. l
.name = "user_led3",: R( Y) [1 E# C' ] p, m$ l, v9 ^2 p
.default_trigger = "default-on",
$ T, r+ @: h$ L2 C1 O3 E },
8 V$ G2 m5 L! y: h8 ~- z% R};
: f! t' j' G$ @6 t# j! T) H, g3 f. z& u
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 ?, n9 h5 T9 y: A5 I/ K .leds = da850_evm_tl_leds,& @ K+ e3 j; n* d
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
]! M0 H8 E; }5 j8 E$ p};
# _6 _# B, c) o8 l5 k1 ]* S
* E: A- Q8 m5 K c; E$ xstatic void led_dev_release(struct device *dev)6 J5 _5 o! v r+ h7 U. U
{) Y3 ~) L, D$ X q
};
/ a( m7 D. C/ \: B' J3 C
5 p) `; g, |. c. Tstatic struct platform_device da850_evm_tl_leds_device = {
# }" {& ]' \) p8 L& ] .name = "leds-gpio",
4 D& z4 I2 P/ o/ U( y1 G .id = 1,
4 d4 e5 a6 J0 V7 _$ ? .dev = {/ t% Z7 t! s; Z# t* f! k
.platform_data = &da850_evm_tl_leds_pdata,7 P% ^. K7 a9 s3 G
.release = led_dev_release,1 m/ i8 j; ]6 K6 H/ T8 m) J
}
' m: Z, d& s, q7 c* i' o};
+ T0 l! B2 H# k" y: a5 c4 a) u: q9 M0 H! v0 T4 M9 q" ]( I
static int __init led_platform_init(void)( V( A2 A' N6 F2 J$ \6 ^: D
{8 e3 D" n' A, y) Z/ q$ O
int ret;9 n8 M3 G# @( K' d) r% b3 T
#if 06 y) e) t4 i$ X- ?
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 M! x _$ l, E3 @ if (ret)
# X, v$ F; z( g" b pr_warning("da850_evm_tl_leds_init : User LED mux failed :". Q7 P5 m! r0 x$ X/ H6 i% p
"%d\n", ret);
/ g) q1 H, O& w% ^; I' m#endif- U: ?. v4 r: q% V# L6 z) X
ret = platform_device_register(&da850_evm_tl_leds_device);' W# K- h j- h4 ]" I1 G
if (ret)
+ v1 n( ?! N, |' S pr_warning("Could not register som GPIO expander LEDS");
6 u* r/ S3 R% B8 L else
/ ]. _- b$ ^4 i' k" ^, ~& O+ ` Y( T: j printk(KERN_INFO "LED register sucessful!\n");& ~4 D: h: a/ \- \
7 T- f9 c/ Z, D7 M6 F5 q3 \
return ret;
% R* t$ [* Z! |- Z! Y h}- t2 g7 t/ D# I) P$ c: U
1 R: c5 A- N+ b0 Q" _( o4 Y+ dstatic void __exit led_platform_exit(void)
' e( I4 u( O3 e7 ?' r{
) ^) r7 T- ?# y" g6 T# a9 X* ` platform_device_unregister(&da850_evm_tl_leds_device);
$ J3 _9 ^! J% `! B
# [, n" U) K+ W. \' b" f: _: K printk(KERN_INFO "LED unregister!\n");
& Y2 w3 p1 k/ E}( {8 z3 J0 I( s
* E5 T o9 V6 z" E3 t- f$ Jmodule_init(led_platform_init);+ a! L( w+ w+ g% T* G" g9 X
module_exit(led_platform_exit);* K4 g0 W) V9 l! N% L; ^" H
/ L$ Y$ e. S& d+ i
MODULE_DESCRIPTION("Led platform driver");$ [; a# ?5 {( _4 ~# |8 V
MODULE_AUTHOR("Tronlong");
& z) k6 @5 H3 i. c# LMODULE_LICENSE("GPL");
) m* A$ X) E4 l
- w+ G5 g- J& m |
|