|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 M. ~) c" f4 M4 Q0 c% l
#include <linux/init.h>
# x4 W6 ?- ]5 _. \7 b#include <linux/module.h>2 m# `) z/ L0 Q2 ?) T" \6 o9 d% U
#include <linux/kernel.h>
7 y' _% R; U4 Q1 [+ x$ O#include <linux/types.h>
' G b h* @. H. a1 k3 r* k#include <linux/gpio.h>
( C4 ]7 v/ j" G7 m#include <linux/leds.h>
2 [% m5 A: |, q- ]#include <linux/platform_device.h>
) v0 ]+ x. }, @% ]8 m$ D, x# @
#include <asm/mach-types.h>
/ d% ?6 o. \, A0 p. G3 y$ u6 l6 u#include <asm/mach/arch.h>
& N& G( C }' c4 {( S) _9 l$ B, ~#include <mach/da8xx.h>
$ A/ s( m* x N1 Y5 }- A0 S$ T#include <mach/mux.h>
' w/ f" F! @0 C" p( r4 x% e, F2 B
1 h/ o. h2 D, |#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 c1 S1 x# j) v. D8 D, \! b; d7 `
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
k- f1 P% X. T/ ^#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 z+ u# L0 H: z( h% s#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 A, g! \, n. }, G2 J* O) m. g
! O7 @& o/ ]* w, Q5 e9 B1 |6 r5 h
/* assign the tl som board LED-GPIOs*/$ Y9 k$ T- V0 T( H* _) F
static const short da850_evm_tl_user_led_pins[] = {7 q7 y$ Y' @, I; s( l; ?
/* These pins are definition at <mach/mux.h> file */% z; ~! M/ n' A( q% {% ? h
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% _1 C; v8 X9 l
-17 I# Y( j0 v. O+ `
};- j l5 @+ r' @( W
C/ e* A+ t& g1 C; ^. p& [. v8 ~. ?static struct gpio_led da850_evm_tl_leds[] = {, l% c% m% j5 X) O% d; i" \( Y
{* Y: U* F1 o' E& Y
.active_low = 0,
1 P1 W2 \1 S q; ^, f- F( n .gpio = DA850_USER_LED0,
% X6 M4 m6 M \) t4 Q" s .name = "user_led0",
9 a( v/ W0 r3 f8 Y' @: A. x .default_trigger = "default-on",# P' z2 ]+ F* I) `& V4 R2 `4 l2 c
},4 M( c/ M& i8 o) b. h
{+ m ^- _! S/ |; x3 e9 Q) @
.active_low = 0,
@4 W' g+ m5 c- n$ C .gpio = DA850_USER_LED1,+ o; n3 {0 u& o" v2 i2 a
.name = "user_led1",
" e* f, c) `3 W! |' d .default_trigger = "default-on",, {* `, j8 b* J' J- B
},
2 O @* n7 J# L& f. T1 ^( {7 j {5 H0 \6 @+ d/ k4 e
.active_low = 0,) ?( p, m4 {5 k1 z& ~: A$ K! H
.gpio = DA850_USER_LED2, c. n* R; e( q$ Z+ d
.name = "user_led2",# l( a0 Z% e3 b0 E/ y2 N
.default_trigger = "default-on",
3 N& @( P! j+ g; z9 d* R( A5 w! E },
5 t- }! ^# j N! t {7 Q6 \7 t# d# t/ w8 c
.active_low = 0,
: C# y M: d" p8 a6 v7 }* V .gpio = DA850_USER_LED3, S# T7 N4 d5 [0 K
.name = "user_led3",% x C6 S( {1 U( [8 p; g0 \
.default_trigger = "default-on",; W# H9 s3 y+ c7 w
},
3 I- R' {, ^! e( ` |2 p t. R! F};
! t/ s6 Z6 q* m( U2 a
6 `8 J1 c& Z% W0 Astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = { {6 B; r1 Y! b: ~) f5 K, Y
.leds = da850_evm_tl_leds,
9 a$ U- Z [$ W3 }; o .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: x7 D; I: F0 T- A3 q$ N
};% ?8 `5 [6 F: m5 y% \
7 T* G4 S$ J; Q0 f- C
static void led_dev_release(struct device *dev)7 ]9 m ~* \& ]: l- H' l: p- f
{
7 ~( x, N r6 Q1 F2 h) M1 S2 U};
) X/ E, d' j* m1 ^0 d8 u* }8 W. H) R: a6 w4 ^. E6 F* j/ Q- y
static struct platform_device da850_evm_tl_leds_device = {
. F& t" @; ]/ i* [% V, M .name = "leds-gpio",# ^) O# y w9 b* D+ m" z5 U
.id = 1,( y$ [* B% e( `! M
.dev = {
: ~4 i- o6 l7 A- Z .platform_data = &da850_evm_tl_leds_pdata,: F" n& r0 n/ s. f
.release = led_dev_release,/ S+ O! i* e* L8 i- ^) O
}* Q q: C/ G* y. z
};$ ?9 \# L* N q/ E" ~7 g0 Q
& t0 a: y' [9 M2 Z
static int __init led_platform_init(void). y+ ]8 G& D- z- \+ b8 Y: r0 ^+ u
{
( G& Y, V5 v+ S3 p( M int ret;. r8 L: |) Z! d9 z7 ]/ F* j
#if 0
. S0 h- d- z+ c5 C0 i, O* G& d4 I ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ |* I- C1 @# y
if (ret)
" e# `6 ]6 W* K pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ x# ~2 l% o3 ^7 s' c "%d\n", ret);: z' y; b' Q4 u; X
#endif. b4 C( Z- q% h+ S; |+ d
ret = platform_device_register(&da850_evm_tl_leds_device);
' D# J' V W, `0 n8 \3 [2 m E2 ?! y if (ret)1 J: w B9 ]. B) D
pr_warning("Could not register som GPIO expander LEDS");
! {4 s' b4 ~" o/ M( v Z$ u else* f' P& K: v5 N: _- p
printk(KERN_INFO "LED register sucessful!\n");# Y5 U! e$ l7 V. c/ q3 ]
* A1 w/ y/ U+ p% I
return ret; X9 z$ K; u; p W
}
! h& q; S$ L* U; d$ N' r; W0 Q. P+ X
static void __exit led_platform_exit(void)
8 x: ]- {9 G# {{0 z- j6 B& _. g8 ^* \' q w, S! a/ z
platform_device_unregister(&da850_evm_tl_leds_device);
6 U2 y3 M! I+ q8 `; a; X6 L
8 z- J# y4 j- U8 \# Y printk(KERN_INFO "LED unregister!\n");( U' ~; }+ |8 D; Y+ S+ p7 n
}
9 I) O$ H/ y P( [! T, S4 p+ n# e/ u! f5 ?; Z' _/ {9 A
module_init(led_platform_init);2 {; s, H7 p) Z* P J. {
module_exit(led_platform_exit);# _6 ^* ?6 p- f; V4 f5 G0 i
: R" ~, B) c8 Y# UMODULE_DESCRIPTION("Led platform driver");
+ G6 M8 J- \9 p! U" d$ @, hMODULE_AUTHOR("Tronlong");
# Y, \0 V' V, M3 ^3 H% fMODULE_LICENSE("GPL");
' U' y, T2 W2 {5 }8 {3 _" t
0 g- y# ~0 p1 e+ I, J% ?* o" c |
|